0

我是一個使用基於聲明的身份的ASP.Net MVC應用程序。我創建了一個安全令牌服務(STS)進行身份驗證。我的MVC應用程序託管在IIS默認網站上。我的應用程序運行完美。但腳本不起作用。目前我已禁用匿名身份驗證(這是要求)。謝謝。腳本和樣式不能在基於聲明的身份中工作

錯誤消息: enter image description here

回答

2

最後我得到了解決方案。

對於基於身份的權利,我們必須以配置webconfig如下:

<modules> 
     <remove name="FormsAuthentication" /> 
     <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" /> 
     <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" /> 
    </modules> 

它將工作。

謝謝大家.............

+0

你知道嗎,這是否也是MVC5似乎使用基於聲明的模型的要求。 – Tim

+0

對不起,我沒有得到你... –

+0

你指定的web.config部分,它不是在我的web.config中從一個vs2013預覽MVC5模板。所以問題是,如果我在MVC5中使用新的基於聲明的模型,我應該有你指定的web.config模塊部分?或者,我假設Windows窗體身份驗證應該在網站上禁用。 – Tim

1

你應該允許訪問腳本文件夾中的所有請求,這增加的web.config。也允許以同樣的方式訪問CSS文件夾。

<location path="Scripts"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
</location> 
+0

我已將此代碼添加到webconfig文件中。但不工作。在IIS中,我禁用了匿名身份驗證。 –

+0

另外我的腳本路徑是http://localhost/Framework/dept/cdadepst.js .......然後我怎麼才能添加位置路徑...你能給我一個解決方案嗎? –

+0

確保你給出的路徑是正確的。你只需要指定相對路徑。 – ssilas777

相關問題