My Working Application MVC3 Razor Unexplainably st

2019-12-16 17:42发布

问题:

I have the following projects within my solution.

  • MyWebApplication.Data --> Here i interact with my Data Repository
  • MyWebApplication.Services --> Here i interact with the Data Layer
  • MyWebApplication.Web --> The UI which relies on the Service Layer
  • MyWebApplication.Tests --> Unit testing project

For MONTHS i have had NO problems with IIS in my local dev environment. Ready for a long weekend of programming but all day i have been getting 500 Server Errors when simply trying to resolve the Home page. Before I went to bed all was well, the entire day thereafter i could NOT even load the home/index view.

After looking at the logs it says continually MyWebApplication.Data.System (which is a class i created called System()) does not include Web. But no where in code is this true. Then i get another error of mismatching files in the Temp Directory.

Steps I have taken:

  1. Deleted all temp files
  2. Created a new repository in IIS and pointed URL there, No luck
  3. Cleaned solution
  4. Deleted all bin folders to have regenerated... No Luck

PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

回答1:

Without the details of the error messages, one strategy may be to create a new MVC project and copy/paste the files over to it. A few other common causes:

  • Are you referencing any 64-bit libraries but compiling the project as 32-bit (or vice-versa)? Try changing the "bitness" of your application.
  • If your application is 32-bit and is running on a 64-bit server, you need to enable running 32-bit apps in IIS. See http://exhibita.com/blog/post/2010/03/30/IIS-75-on-x64-with-32bit-applications.aspx
  • If all else fails, please post the exact error messages. If all it says is "HTTP 500: Internal Server Error", you should enable debug output or run your app from the server itself (actually using a web browser on the server), which will tell IIS it's "safe" to display full debug information. The debugging messages have actually been pretty useful in my experience.


回答2:

Figured it out. In

  • MyWebApplication.Web project, within the Shared/Site.Master I added a imported a reference to my Data Layer. (i.e., <%@ Import Namespace="MyWebApplication.Data" %>

  • I resolved by removing the static reference to my ShoppingCart class in the Data layer and just created an ActionResult to return the same and in the MasterPage (which currently holds the javsscript to allow the user to peek into their cart from anywhere in the site without a redirect to a specific page) used the Html.RenderAction() and just returned Content(shoppingCartString).

Guess I have learned that within the Site.Master page it is complied differently than every other page in an MVC application. I can positively say this because in other pages I am doing exactly as I attempted to do here without any issues. Maybe its the build process?

Anyhow, problem solved and hopefully it can help someone else too.