MVC5在哪里将身份验证表单放在web.config中? [英] MVC5 Where to put authentication forms in web.config?
问题描述
在此标题之后,在我的web.config中,它是由VS 2012生成的.
Following this title, in my web.config, it's generated by VS 2012.
现在,我不知道我将下面的代码放在web.config中的哪个位置,因为我看到有人将它放在<system.web>
中,但是在我的web.config中,它只有<system.web.webPages.razor>
和<system.webServer>
.当我将此代码放在web.config中的某个位置时,在<authentication mode="Forms">
处出现错误:
Now, i don't know where i put the below code in web.config through i saw someone put it in <system.web>
but in my web.config it have only <system.web.webPages.razor>
and <system.webServer>
. When i put this code somewhere in web.config I get an error at <authentication mode="Forms">
:
有代码:
<authentication mode="Forms">
<forms loginurl="~/Comfirm/Login" timeout="2880"></forms>
</authentication>
推荐答案
您将其放在错误的web.config文件中.有两个web.config文件. Views
文件夹中的一个,站点根目录中的一个.将其放在网站根目录中的web.config文件的system.web
标记中
You are putting it in the wrong web.config file. There are two web.config files. one in Views
Folder and one in the root of the site. put it in the system.web
tag of the web.config file in the site root
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<connectionStrings />
<appSettings >
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="owin:AutomaticAppStartup" value="true" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Comfirm/Login" timeout="2880" />
</authentication>
</system.web>
<!--other configuration-->
<configuration>
这篇关于MVC5在哪里将身份验证表单放在web.config中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!