0

I ́m working on an ASP.NET MVC project, that does the following:

Users collect data using an android app, this data is being sent as json. This app is under development by someone else, not me, but we ́re in contact.

I created a JSONController with the following action:

 [HttpPost]
 public JsonResult PutJSON(JSONModel json){
 // do something
 }

My JSONModel only contains a public string LastName for testing purposes.

For now, I can only publish the project to IIS on localhost, which can be accessed from other devices in my home network. As far as I know, that should be okay for testing, right? The project is accessible and works when entering the ip of that machine in a browser on another device in network.

Is there anything else I need to do in my ASP.NET MVC project to make it accept AJAX calls from "outside"? Am I missing something?

I tried to test with a simple AJAX call from another device, but that ́s just giving me internal server errors, because of cross domain call. Accepting those cross domain calls didn ́t work though (do I need this when the project is finally being published?)

I ́d be very thankful if someone could help, maybe by providing a link to a tutorial explaining how to configure ASP.NET project to accept AJAX calls from the internet.

asked Jun 22, 2017 at 11:22
3
  • Hi, I suggest you to first read the concept of cross-origin requests: en.wikipedia.org/wiki/Cross-origin_resource_sharing and then you can refer to this topic to configure asp.net properly to accept your desired requests: stackoverflow.com/questions/6290053/…. Keep in mind that enabling all sources might make your page vulnerable to dangerous scripts. Commented Jun 22, 2017 at 11:39
  • I followed the instructions before already, but that didn´t solve my problem. Enabling CORS for certain origins is not what I need for that project when sending json from an app, right? Commented Jun 22, 2017 at 11:45
  • Hello @MeMySelf, did you created a Web API project? or it is only an MVC project? Commented Jul 7, 2017 at 12:21

1 Answer 1

0
answered Jun 22, 2017 at 11:50

3 Comments

I did read that posts before, too ;) Basically I just need to know if it is enough to have my Action like shown above for accepting AJAX calls from the internet. It works perfectly when sending a call from View with jQuery.
Can you please check if you can reach your site pages from where you're trying to access the action?
The pages (and IIS and so on) are running on my local workstation, and are accessible from devices in my network. From a view on my workstation I can pass json to my action, but from any other device in network that isn´t possible.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.