0

I have a Windows Server 2012R2 running IIS version 8.5.9

Currently it has a single ASP.net Forms web application running on the default http port 80. The website has an application pool (v4.0 Classic). The website files are stored in c:\inetpub\wwwroot\formsApp.

( The application can be accessed in a way similar to: http://server-host-name.company.com ) This works fine, with no issues.

I created a new ASP.Net MVC application and published it to c:\inetpub\wwwroot\mvcApp. I also created a dedicated pool (v4.0 Integrated) and configured it to run on port 8080. The application works perfectly when I visit: http://server-host-name.company.com:8080.

Now, I created a virtual folder in the formsApp website in IIS and pointed it at mvcApp folder. I also made sure that the pool used for the virtual folder is the Integrated pool, not the classic. The virtual folder name is mvc.

I could tell that IIS did something special to that folder, since its thumbnail icon is no longer a normal folder, but an application website thumbnail.

Now when I go to http://server-host-name.company.com/mvc I can see the page being loaded and the correct controller is called, the view is rendered, but the static script and CSS files are not loaded. When I examined the network log in the browser, I noticed that any request to the script or CSS static content is redirected to the Login Page, since the MVC app has Forms Authentication.

I have looked everywhere how to resolve this issue. Some answers pointed out that I should add a line in Web.config to add the line

 <modules runAllManagedModulesForAllRequests="false" />

But that did not work. it had no effect, as the same page loaded without CSS or JS. But besides the fact that it worked or not, it does not explain why the app worked fine when IIS served it off of port 8080, without having that line included in Web.config.

Edit: Just to clarify, after the app runs from the virtual directory, the links/urls to the static files are valid with the name mvc prepended to them as expected.

How can I resolve this issue?

Ahmad
  • 12,336
  • 6
  • 48
  • 88
  • What are the path(s) that the HTML is rendering for your CSS/JS? I suspect that the paths that are rendering in your HTML do not match you new virtual directory path. – Tommy Apr 05 '21 at 12:16
  • the paths for the app within the virtual directory is correct. all the css and js links are updated with the `mvc` name prepended for all urls. @Tommy – Ahmad Apr 05 '21 at 13:24
  • I just saw where you said you are getting an authentication redirect. A possible reason is that the parent application you are running the virtual directory in has some permissions that are being forced down to your app (it is inheriting its security settings and are conflicting with what you expect if that makes sense). That could be why it works in a standalone site but not as a child application of the parent `formsApp` site. – Tommy Apr 05 '21 at 13:55
  • @Tommy that can be the case. The `mvcApp` has a directive in its `web.config` to remove `` and thus, I can't add the line `` so I have to switch between the two. How can I keep both directives? – Ahmad Apr 05 '21 at 14:10
  • Its been awhile since I've had to configure IIS since we've moved most everything to the cloud....I'm glad to have potentially helped narrow down the cause but I unfortunately don't have a solution for you :( – Tommy Apr 05 '21 at 14:19
  • It should be noted that when adding static files as virtual directories, they must be added under the main application. There is a similar issue in this link: https://stackoverflow.com/questions/65959265/flask-static-folder-not-served-on-iis/66022090#66022090 – Ding Peng Apr 06 '21 at 05:07

0 Answers0