1

I am using ASP.NET MVC 4 Mobile application, in which I am trying to redirect to an external website. However its failing with "Error loading page" message.

public void RedirectToGoogle()
{
    Response.Redirect("http://www.google.com");
}

Also I see the following script in _Layout.cshtml which is created automatically while creating the application.

<script>
    $(document).bind("mobileinit", function() {
       // As of Beta 2, jQuery Mobile's Ajax navigation does not work in all cases (e.g.,
       // when navigating from a mobile to a non-mobile page, or when clicking "back"
       // after a form post), hence disabling it.
       $.mobile.ajaxEnabled = false;
   });
</script>

I tried changing $.mobile.ajaxEnabled to true, but no success.

Any thoughts on how to do url redirecting in ASP.NET MVC 4 Mobile application?

1 Answer 1

1

Response.Redirect is for WebForms and uses the WebForms page lifecycle. For MVC you should use return Redirect("http://www.bing.com");

I've reproduced the problem on ASP.NET MVC 4/Beta with a mobile project. It's a CORS (Cross Origin Resource Sharing) issue. See http://www.webdavsystem.com/ajax/programming/cross_origin_requests

Use the F12 developer tools to Fiddler to see the problem.

EC7118: XMLHttpRequest for http://www.bing.com/ required Cross Origin Resource Sharing (CORS). localhost:52137

SEC7119: XMLHttpRequest for http://www.bing.com/ required CORS preflight. localhost:52137

Sign up to request clarification or add additional context in comments.

1 Comment

What is the solution? I am getting the below errors: SEC7118: XMLHttpRequest for docs.google.com/spreadsheets/d/… required Cross Origin Resource Sharing (CORS). SEC7119: XMLHttpRequest for docs.google.com/spreadsheets/d/… required CORS preflight. SEC7120: Origin localhost:18591 not found in Access-Control-Allow-Origin header. SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.

Your Answer

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.