2015-04-20 14 views
0

我正在用VS2013做一个ASP.NET MVC Web应用程序。本机Windows服务器企业,SP2和IIS 7ASP.NET/MVC:在上下文中找不到owin.Environment项

我得到了以下错误:

Server Error in '/' Application. 
No owin.Environment item was found in the context. 
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.InvalidOperationException: No owin.Environment item was found in the context. 

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: 

[InvalidOperationException: No owin.Environment item was found in the context.] 

我用Google搜索,并找到了解决方案,并做了这样的事情(加入<add name="OWIN".... >)在web.config中:

<system.webServer> 
    <modules > 
     <remove name="FormsAuthenticationModule" /> 
     <remove name="UrlRoutingModule-4.0" /> 
     <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> 
    </modules> 
    <handlers> 
     <add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" /> 
    </handlers> 
</system.webServer> 

这样做后,网络应用程序的作品。然而,所有的静态文件,如CSS和Javascript都没有被浏览器找到(所有这些静态文件都是404),所以我的应用程序没有风格。

什么是配置

<handlers> 
    <add name="OWIN" path="*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" /> 
</handlers> 

让我的应用程序的工作权的正确方式?或者我需要做点别的?

谢谢!

回答

1

经过多次测试,我得到了它的工作。这是我做的:

<add name="OWIN" path="/Account/*" verb="*" type="Microsoft.Owin.Host.SystemWeb.OwinHttpHandler" /> 

请注意上面的路径属性有一个特定的路径。我所有的javascript和css文件都在其他顶级目录下。

我是ASP.NET/MVC专家。如果有人有更好的想法,请让我知道!

干杯。

相关问题