0

I have several applications deployed to IIS. I created a site for each application and mapped them using different port number. Recently, I was asked to use virtual directory instead of mapping them using different port number. I created the virtual directory and add a route for it. When I tried to test the application locally, I was getting a 403.14. After reading several post online, I made the following changes to my web.config file

  <modules>
      <remove name="UrlRoutingModule-4.0"/>
      <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule, 
        System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
          preCondition="" />
    </modules>

I am not getting a directory with all the files name. I updated my route in the

RouteConfig.cs file to 
            routes.MapRoute(
                name: "Default",
                url: "CollegeOfBusiness/{controller}/{action}/{id}",
                defaults: 
                 new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
                 namespaces: new[] { "MyCollege.Controllers" }
            );

After making those changes, I am not getting the 400.13 anymore; however, I am not getting the login page. I am getting a directory of all the files. I ran the command "aspnet_regiis /i" and then aspnet_regiis -ir to make sure that it was not a registration issue. I have not had any luck so far. I am looking for any information or resources that could help fix this issue.

Local System: Windows 7 IIS 7.5 Visual Studio 2017 Asp.net MVC 4 Jquery 2.3

Update 07/03/2018 @9:45

I modified the route as shown below. I am not getting the directory listing anymore. However, POSTs and GETs are not routing to the appropriate controller. The url when the page first loaded looked as shown here:

http://localhost/CollegeOfBusiness

I added the custom route below. It is added right above the default route.

RouteConfig.cs file to 
        routes.MapRoute(
            name: "CollegeOfBusiness",
            url: "CollegeOfBusiness/{controller}/{action}/{id}",
            defaults: 
             new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
             namespaces: new[] { "MyCollege.Controllers" }
        );

Then, I add the default route at the bottom.

RouteConfig.cs file to 
routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: 
     new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
     namespaces: new[] { "MyCollege.Controllers" }
);

When the user clicked on login button, the post URL looked as follow:

/CollegeOfBusiness/Account/Logon
Jean B
  • 343
  • 1
  • 6
  • 19
  • Try converting your virtual directory into sub-applicaiton. Right click on the virtual directory in IIS Manager and then click `Convert to Application`. – Mohsin Mehmood Jul 02 '18 at 20:20
  • The virtual directory was added as an application. – Jean B Jul 02 '18 at 20:32
  • Do you see `Convert to Application` option when you right click on the virtual directory in IIS Manager? – Mohsin Mehmood Jul 02 '18 at 20:38
  • Right click on the default site and clicked add application. – Jean B Jul 02 '18 at 20:43
  • Have you tried removing CollegeOfBusiness from default route? I am assuming CollegeOfBusiness is your sub-application name – Mohsin Mehmood Jul 02 '18 at 20:48
  • It did load the login page. However, I could not logged in because the script could not be loaded – Jean B Jul 02 '18 at 21:26
  • Please modify your question to use "IIS application" instead of "IIS virtual directory". Like the comments indicated, the wrong terms only led to extra cost. – Lex Li Jul 02 '18 at 23:38
  • When I removed the CollegeOfBusiness, the page loaded fine. However, the resources and assets were not loaded. They returned 404 instead. I found a few post that talked about using html helper to crrate links and url. The problem is that I can not use HTML Helper because the JavaScript file are in separate folders. – Jean B Jul 03 '18 at 01:01

1 Answers1

0

Finally, I was able to get it to work. 1. I removed the below custom route because it was not needed.

RouteConfig.cs file to 
        routes.MapRoute(
            name: "CollegeOfBusiness",
            url: "{controller}/{action}/{id}",
            defaults: 
             new { controller = "Account", action = "Logon", id = UrlParameter.Optional},
             namespaces: new[] { "MyCollege.Controllers" }
        );
  1. As suggested in this POST, I added the url to a div and get it based on the Id. I also change the src for all js and css file to use @Url.Action().

  2. I had to prepend '/CollegeOfBusiness' in front of all requests

  3. I changed the application pool to use a service account. This account did not have access to update the database, so I fixed that as well.

Jean B
  • 343
  • 1
  • 6
  • 19