MVC 4 403 and 404 error

Scenario: I deployed a MVC 4 site to IIS7 server and when I would nav to the root http://domain.site.com/ it would give a 403 permission error. If I tried to go directly to the controller/action (http://domain.site.com/controller/action), I would get a 404 error.

Trying to load the page on the server, I could see the detail that the it was trying to use the staticFile handler, which is wrong!

I found an article that showed how to set the default controller in the web.config rather than the code, and by doing that I was able to see that the Newtonsoft JSON package was giving an error. This I’ve seen before so I checked my nuget packages, changed them all from net451 to net40, (my project is set to compile as 4.5 not 4.5.1).

I redeployed. Same error. The static handler is still firing rather than .net handler. I added

<modules runAllManagedModulesForAllRequests="true" />

to the

<system.webServer>
section.

Now it loads normally. Next time I load a new site and do all of this I will try adding that to the web.config first and the see if less needs to be done with updating the nuget packages.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s