1

I have an asp net 4 application. When I run it on Visual Studio 2015, it runs perfectly. When I publish it to my local IIS Express(v10), again it runs nicely with all default configurations. However, when I deploy it to production server which have IIS 6, again its running normal but I am getting the following error.

Server Error in '/' Application.

The remote server returned an error: (403) Forbidden.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[WebException: The remote server returned an error: (403) Forbidden.]
   System.Net.HttpWebRequest.GetResponse() +8418416
   Truvo.Web.AdvertiserLounge.Controllers.BusinessClaimingController.MakeSearchCall(Boolean advancedSearch, Boolean cache, String view, Int32 log_top_n, String adrecip, Int32 pageSize, Int32 offset, Boolean excludeZone, String what, String where, String locale, Boolean rotate) +925
   lambda_method(Closure , ControllerBase , Object[] ) +679
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +270
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +120
   System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +452
   System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
   System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +33
   System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +240
   System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
   System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

I have followed the following questions:

403 - Forbidden: Access is denied. ASP.Net MVC

I did add the IIS_IUSRS, changed autonomous login to app pool.

I don't really know what is going on and looking for a help. Thanks :)

user2084339
  • 41
  • 2
  • 4
  • When you say "add the IIS_IUSRS" what do you mean? Typically I create a memory pool in IIS, assign a user to it, and then assign that user folder permissions to where the app. is stored. You may also want to have a look here, specifically IIS6 with MVC http://stackoverflow.com/questions/3132368/can-i-deploy-net-4-0-web-application-on-iis6 – Phill Mar 16 '16 at 12:35

1 Answers1

0

Based on the stack trace, it seems as if a remote web server is responding the 403 to the application shown in your call stack. The only difference I can think of besides permissions is that you'll probably need to turn on ASP.NET Impersonation. When you run IISExpress or locally, these worker processes run under the context of your account. This is not the case when running in a production web server. If this is an IIS 6 box, try adding ASP.NET impersonation to your application as such:

<configuration>
    <system.web>
        <identity impersonate="True" />
    </system.web>
</configuration>

NOTE

If you're running in any IIS 7.0+ web server and in Integrated Pipeline mode, you will also need to add the following to the web.config file:

<system.webServer>
    <validation validateIntegratedModeConfiguration="False" />
</system.webServer>

If not done, you will get an error when enabling ASP.NET Impersonation. Hopefully this helps.

NOTE 2

If you don't have any authentication method in your application, you'll need to try impersonating a specific account then by using the userName and password attributes in the identity element.

milope
  • 346
  • 1
  • 6