Muhammad Murad Haider
Muhammad Murad Haider

Reputation: 1467

Enabling CORS in MVC application (to be deployed on azure)

I know there are a number of questions on this forum stating the same problem statement. But i wanted to present my particular scenario to get the guideline/suggestion related to that. i am working on an MVC application that is supposed to be deployed on azure (basically it deals with windows azure using .net sdk and other packages). Application works perfectly but after 50 -60 minutes of idle time (i.e. without refreshing), the connect is lost. During debugging the code (through Visual Studio 2015 community edition) i have found that it redirects the flow to Sign in () function (i have not developed that function so i don't have through understanding of that). Here it creates a sign in url (to authenticate with azure AD)and redirects the application to that url. This is the point where application gives error. In browser (Google Chrome) console i found it stating

MLHttpRequest cannot load https://login.windows.net/common/wsfed?wa=wsignin1.0&wtrealm=https%3a%2f%2fdhttps%253a%252f%252flocalhost%253a43778%252f&wct=2016-09-26T19%3a05%3a59Z. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:43778' is therefore not allowed access.

I tried to enable CORS in the application using almost all the methods i.e.

Nothing is seeming to be helping and i can't find headers related to CORS in Requests and responses. What could be the problem with enabling CORS. Please guide. Any help will be greatly appreciated. Thanks

Edit: Actually Application behaves like this while idle, once we refresh the page it's all okay. I was just investigating why the connection is lost and how to keep the application up even after such long idle time. If any thing other than CORS can cause this problem please guide and suggest the possible fix.

Upvotes: 0

Views: 695

Answers (1)

juunas
juunas

Reputation: 58823

Yeah well the CORS header is not missing in your app. It's missing from login.windows.net. If you redirected to that page it shouldn't be a CORS problem. CORS only comes into play when you make a call from JavaScript to another domain. Check the JS AJAX calls. Something is trying to call to login.windows.net, and it's not the redirect.

Upvotes: 2

Related Questions