【问题标题】:MVC IIS7 HttpContext.Current.Profile is nullMVC IIS7 HttpContext.Current.Profile 为空
【发布时间】:2011-11-10 02:28:28
【问题描述】:

我正在尝试设置我的站点以使用 IIS7 MVC 3。

一开始 HttpContext.Current.User 为空,

然后我删除并添加了模型:Session、FormsAuthentication 在 system.webServer 模型中,现在 HttpContext.Current.User 不为空。

但是 HttpContext.Current.Profile 为空,我找不到解决方法。

如果我设置<modules runAllManagedModulesForAllRequests="true"> 它解决了问题,但由于性能问题我不想使用它。

<models> 中 Profile 的 FormsAuthentication 等效模型是什么?

有没有办法在不使用 runAllManagedModulesForAllRequests 的情况下获取配置文件?

Web.Config:

 <system.webServer>
<handlers>
  <remove name="ASP.NET MVC" />
  <add name="ASP.NET MVC" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness64" />

  <remove name="MvcHttpHandler" />
  <add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler" />
  <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />


</handlers>
<validation validateIntegratedModeConfiguration="false" />
<modules>
  <remove name="WindowsAuthentication" />
  <remove name="PassportAuthentication" />

  <remove name="UrlRoutingModule-4.0" />
  <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  <remove name="Session" />
  <remove name="FormsAuthentication" />
  <add name="Session" type="System.Web.SessionState.SessionStateModule" />
  <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />

</modules>

【问题讨论】:

    标签: asp.net-mvc iis-7 asp.net-mvc-routing


    【解决方案1】:

    我找到了模型列表: http://msdn.microsoft.com/en-us/library/9b9dh535.aspx

    最后删除并添加了我使用的所有模块。

    如果您知道在 IIS 7 上使用 MVC 路由获取配置文件和角色的更好方法,请告诉我。

     <remove name="UrlRoutingModule-4.0" />
          <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
          <remove name="Session" />
          <remove name="FormsAuthentication" />
          <remove name="Profile" />
          <remove name="RoleManager" />
          <remove name="OutputCache" />
          <add name="Session" type="System.Web.SessionState.SessionStateModule" />
          <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
          <add name="Profile" type="System.Web.Profile.ProfileModule" />
          <add name="RoleManager" type="System.Web.Security.RoleManagerModule" />
          <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-09-26
      • 1970-01-01
      • 2012-06-06
      • 2013-03-04
      • 1970-01-01
      • 2018-02-12
      • 2015-10-13
      相关资源
      最近更新 更多