403 forbidden after publishing asp.net MVC

2019-02-02 00:19发布

问题:

I know this has been answered a few times but none of the solutions worked for me. I published my ASP.NET MVC 3 application (It was just the internet template without any changes to it) to see if I could get it to work publically. However, when I visit the site it shows up with a 403 error. Coming from a php/linux background, I'm confused and have no clue where to look. I've only been learning .NET for about 8-9 months and everything I've been testing on before was on the local development server through VS2010. It almost appears like the server doesnt know it should be an MVC application or I have to change my routing.

Anyway, I checked to make sure that the server setting is .NET 4. Any help would be greatly appreciated.

ALSO, It's a shared hosting environment using arvixe.

回答1:

For me this did the trick (Original Answer by Mmerrell at Getting 404.0 error for ASP.NET MVC 3 app on IIS 7.0 / Windows Server 2008 )

You actually just reminded me that I needed to fix this issue in an enviroment here. If your situation is the same as mine then it's a simple fix.

Just add the following to your web config:

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 

Make sure your have choosen the "ASP.Net 4.0" App-Pool and not the App-Pool created for your application. Make sure your App Pool uses the "ApplicationPoolIdentity" and NOT NetworkService. Remove the NetworkService permission from your root folder. You dont need it. IIS has an built-in identity (IIS_IUSRS).



回答2:

403 is a forbidden error. Try checking the NTFS permissions of the folder where you deployed, ensure the Network Service user has read permission

Additionally, check the Authentication and Authorization mechanism in the IIS application:

Edited:

.Net Authorization rules



回答3:

I had this same issue after publishing an MVC 4 WebSite to a remote server using FTP Publishing. What ended up working for me was after publishing through Visual Studio, log onto IIS on the remote server, locate the published directory -> right click -> Convert to Application.

Not sure if there is a way to specify this in the web.config/properties, if you don't have access to the server?



回答4:

1- verify that your application is running under .NET 4.0 (you did so)

2- check with the hosting company that it supports the MVC 3 framework on their hosting plan.

3- (works) Bin-Deploy your MVC run-time libraries so you may overcome any requirements on the server.

More bout bin-deploy your ASP.NET MVC can be found here: http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

4- check that "Network Service" has proper access rights to your folder. it basically should have "Read" permission.



回答5:

Don't forget about aspnet_regiis.exe -ir.



回答6:

<handlers>
  <add name="rewrite" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
</handlers>

Ask your hosting provider to add this handlers into webconfig



回答7:

Try changing the Managed Pipeline Mode of the Application Pool to 'Classic' instead of 'Integrated'. Whilst it may not be the final result that you're after (there can be real advantages in using Integrated mode), at least it will point you in the right direction... if it works.