只有CSHTML渲染文本 - 静态页面? [英] CSHTML rendering text only - static page?

查看:228
本文介绍了只有CSHTML渲染文本 - 静态页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个我的previous问题的延续( .CSHTML页面将无法呈现),但我不再得到一个500错误,因此,新的职位。现在我的网页只是渲染纯文本/ HTML(无论我做什么)。

This is a continuation of my previous question (.CSHTML pages will not render), but I am no longer getting a 500 error, thus the new post. My pages are now just rendering plain text / html (regardless of what I do).

我可以得到网页能够正常工作,如果我试图通过WebMatrix3查看它们,但我不能从浏览器中查看它们(localhost或通过Web)。

I can get the pages to work correctly if I try to view them through WebMatrix3, but I cannot view them from the browser (either localhost or through the web).

最近,我意识到,我的网页是设置了ASP.NET 2.0版,我猜不支持.cshtml。于是,我改变了一切为V4.0,但我仍然没有任何运气正常浏览的网页。它只是纯文本。

I recently realized that my pages were set up for ASP.NET v2.0, which I am guessing does not support .cshtml. So, I changed everything to v4.0 but I still don't have any luck view the pages correctly. It's just plain text.

我有:


  • 安装了MVC 3

  • 在Win7家庭premium IIS 7.5

  • 我要加载转换为应用程序的页面的DIR

  • web.config中运行,虽然我不知道还有什么,如果有的话,我需要有它

  • 我的服务器使用HTML,的CSS,.PHP,蟒蛇等正常工作......但我有任何ASP.NET功能可怕的运气(这包括的.aspx)。

  • 我真的不知道我需要把这里还有什么其他的信息,但如果你问吧,我会提供。

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

    修改1

    现在,我只是得到任何.cshtml网页我尝试查看404错误。这件事发生时,我没有在MIME类型之前,但已得到纠正(至少纯文本)当我进入。我不知道什么是要去MIME类型......在这一点上我几乎准备刚刚卸载的一切,并尝试重新开始。 = \\

    EDIT 1:
    Now I am just getting 404 errors on any .cshtml page I try to view. This happened before when I didn't have the MIME types in, but was corrected (to at least plain text) when I entered the MIME type in. I have no idea what is going on... at this point I am almost ready to just uninstall everything and try to start over. =\

    编辑2

    好了,所以我摆脱了我的404和500错误。我最终加入了特权用户的应用程序池(高级设置>流程模型>身份)。它之前设置默认应用作为。现在我得到这样的:

    EDIT 2:
    Okay, so I have gotten rid of my 404 and 500 errors. I ended up adding a privileged user to the application pool (advanced settings > process model > Identity). It was set as defaultAppPool before. Now I am getting this:

    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
    

    任何更多的想法?哦,创建一个新的应用程序并没有帮助,但它是一个好主意。

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

    推荐答案

    这可能是System.Web.WebPages.dll的旧版本被加载到内存中,并尝试将您CSHTML页面转换为一个版本从DLL的网页类。

    It could be that an older version of System.Web.WebPages.dll is loaded to memory, and it tries to cast the your cshtml page to a version of WebPages class from that dll.

    要测试此,尝试看看HTTP模块当前注册:

    To test this, try to see what http modules are currently registered:

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

    在我的情况下,这是:

    ....
    __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
    

    要修理你需要在你的/斌文件夹,或者可能被引用它的一些其他DLL替换System.Web.WebPages.dll的旧版本的问题。

    To fix the problem you need to replace the older version of System.Web.WebPages.dll in your /Bin folders, or some other dlls that might be referencing it.

    这篇关于只有CSHTML渲染文本 - 静态页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆