Getting a global.asax file error when using virtual directories for an MVC application

谁说胖子不能爱 提交于 2019-12-20 05:58:45

问题


I have a working MVC 4 application deployed to an IIS server. I wanted to duplicate this MVC app inside of another website in IIS so I linked the Bin, Views, Scripts, and Images of the working MVC site to the new site using virtual directories. I then copied the global.asax and web.config files to the root directory of the new site. When reviewing the new site's content view, it looks identical to the original's site directory layout, except that folders are virtual.

When I go to run the new site in a browser, I get the following error:

Parse Error: Parser Error Message: Could not load type 'PrApp.MvcApplication'.
<%@ Application Codebehind="Global.asax.cs" Inherits="PrApp.MvcApplication" Language="C#" %>

I've read up on this, but could not find anything on point. Most dealt with bad assemblies or missing namespaces but since I know the assemblies work I am not sure why I would be receiving this error. My assumption is that this website would function exactly like the other since the files and dll's are all "present" but perhaps this is a bad assumption due to my lack of experience with complied code.

My goal is to run the same mvc app within multiple IIS sites so they each can have their own root directory while I can maintain a single code base.

Any help is greatly appreciated!

UPDATE: Image of IIS. - Highlighted site is the one with the virtual directories. The other expanded site is the working MVC app.

UPDATE 2: I removed the global.asax file from the root of the secondary site and the error went away. NOw I am getting the following error: 403 - Forbidden: Access is denied. I have also tried converting my virtual directories to applications but to no avail. I'm not sure if this is progress. Please let me know if you have any suggestions.


回答1:


Ok. Well as nothing seemed to offer exactly what we wanted, we ended up building out real directory structures for our hosted sites and then created html pages in each that communicated with the app via webAPI and/or iFrames depending on what is required.

The only other thing I could think of was to somehow maintain the same code base across thousands of sites programmatically. If anyone has any other ideas, I'm all ears!



来源:https://stackoverflow.com/questions/15961052/getting-a-global-asax-file-error-when-using-virtual-directories-for-an-mvc-appli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!