CSHTML text rendering only - static page?

This is a continuation of my previous question ( .CSHTML pages will not be displayed ), but I no longer get 500 errors, thus a new post. My pages now just display plain text / html (no matter what I do).

I can make the pages work correctly if I try to view them through WebMatrix3, but I cannot view them from a browser (either local or via the Internet).

I recently realized that my pages are configured for ASP.NET v2.0, which I assume does not support .cshtml. So, I changed everything to v4.0, but I still could not manage to view the pages correctly. This is just text.

I have:

  • Installed MVC 3
  • IIS 7.5 on Win7 Home Premium
  • The registry of pages I want to download is converted to an application
  • Web.config works, although I'm not sure what else if I need something to be in
  • My server works fine with HTML, .css, .php, python, etc. But I have terrible luck with any ASP.NET functionality (including ASPX).

I really don't know what other information I need to put here, but if you ask for it, I will provide it.

EDIT 1 :
Now I just get 404 errors on any .cshtml page I'm trying to view. This happened earlier when I did not have MIME types, but it was fixed (at least for plain text) when I introduced the MIME type. I have no idea what is happening ... at the moment, I'm almost ready to just delete everything and try to start all over again. = \

EDIT 2 :
Ok, so I got rid of my 404 and 500 errors. As a result, I added a privileged user to the application pool (advanced parameters> process model> Identity). It was previously installed as defaultAppPool. Now I get the following:

Type 'ASP._Page_default2_cshtml' does not inherit from 'System.Web.WebPages.WebPage'. 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.Web.HttpException: Type 'ASP._Page_default2_cshtml' does not inherit from 'System.Web.WebPages.WebPage'. 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: [HttpException (0x80004005): Type 'ASP._Page_default2_cshtml' does not inherit from 'System.Web.WebPages.WebPage'.] System.Web.UI.Util.CheckAssignableType(Type baseType, Type type) +9633480 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +66 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(String virtualPath, Type requiredBaseType) +28 System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType(String virtualPath) +203 System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +145 System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType(String virtualPath) +153 System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +73 System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) +23 System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +349 System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +89 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69 

More ideas? Oh, and creating a new application didn't help, but it was a good idea.

+1
source share
1 answer

Perhaps an earlier version of System.Web.WebPages.dll is loaded into memory and tries to pass your cshtml page to the version of the WebPages class from this DLL.

To check this, try looking at which http modules are currently registered:

 var allModules = HttpContext.Current.ApplicationInstance.Modules; for( int i = 0; i < allModules.Count; i++ ) { Trace(allModules.GetKey(i)); } 

In my case, it was:

 .... __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_bca8e05a-5746-45b0-be95-2b920b455ccf __DynamicModule_System.Web.WebPages.WebPageHttpModule, System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35_c1a67b42-31a9-47f1-8483-9e712fabe2a7 

To fix this problem, you need to replace the older version of System.Web.WebPages.dll in the / Bin folder or some other DLL that may reference it.

+1
source

Source: https://habr.com/ru/post/1496649/


All Articles