Jawad
Jawad

Reputation:

ASP.Net MVC Controller causing Not Found error when deployed to IIS 7

I am developing a website using ASP.Net MVC. I have a method in the Home controller which returns a partial view when called. The issue is when I am calling the controller method using jQuery, I get a 404 Not Found error.

This only happens when the application is deployed on IIS 7. It works fine during development, but after deployement, none of the controller are found when called through jQuery.get method or post.

Thanking you all in advance for helping me.

Upvotes: 2

Views: 8954

Answers (7)

Milan Raj
Milan Raj

Reputation: 65

I had same problem. solved issue by changing the ajax url. Just for an example , if you are using ajax call to the controller: have to write url as like this == url: '@Url.Action("actionmethod", "controller")', instead of ===== url: '/controller/actionmethod',

Thanks

Upvotes: 0

Chris McBride
Chris McBride

Reputation: 51

I had the same problem. The simple fix for me was to do a aspnet_regiis -r

Upvotes: 2

LordHits
LordHits

Reputation: 5083

If you are running ASP.NET MVC on IIS7, make sure you configure IIS to run in "Integrated Pipeline Mode" as opposed to "Classic". You'll have more success with routing in this mode. More here.

Upvotes: 0

Th3Fix3r
Th3Fix3r

Reputation:

If you are deploying your mvc app as a virtual web make sure that BOTH your virtual web and the root site has its Application Pool set as Integrated Pipeline.

Upvotes: 0

R N
R N

Reputation: 73

Make sure you have ASP.NET MVC installed and running. Also, make sure that your application is installed properly with appropriate references.

Like Tony says above, make sure you can actually access the complete URI (controller/method) in a browser to see if it works ok.

what is the URL that the jQuery.get method is accessing?

If it does, check how you have wired your Ajax call.

Do the method in your code have the AcceptVerbs attribute defined? [AcceptVerbs(HttpVerbs.Post)]

Upvotes: 0

Jawad
Jawad

Reputation:

Actually, the website is running, I can navigate among pages, only if there is a call through jQuery.get or post methods, then the error occurs. I guess, there is an issue with ISS 7 regarding recognizing that its a controller method. The error text is given below.

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable .

Thanks.

Upvotes: 0

Darko
Darko

Reputation: 38860

is the error an asp.net error (yellow and red) or the default iis7 html error? if its iis7 default error, make sure IIS7 has asp.net installed, that caught me out when i first started working with it. (programs and features and add windows components and make sure asp.net is selected under IIS)

Upvotes: 1

Related Questions