首页 热点专区 义务教育 高等教育 出国留学 考研考公

.NET问题 .NET web.config文件如何引入到程序里的。我配置好了web.config文件。但是每个配置好像都无效。

发布网友

我来回答

4个回答

热心网友

<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
是不是配置有问题
web.config文件常用配置说明如下:
<configSections>
</configSections>
<appSettings>
<add key="identifier" value="63B362AB3FE9FA8DEEB2C1E38274A30" />
</appSettings>
<!--连接数据库字符串-->
<connectionStrings>
<add name="LocalSqlServer" connectionString="Server=.;database=XXX;uid=xx;pwd=xxxxxxxxxxxxx;" />
</connectionStrings>
<microsoft.web>
<converters>
</converters>
<webServices enableBrowserAccess="true"/>
<profileService enabled="true" setProperties="bulletin" getProperties="bulletin" />
</microsoft.web>
<system.web>
<!--<anonymousIdentification enabled="true"/>-->
<!-- 这里为profile信息 -->
<profile >
<properties>
<add name="xxxx" defaultValue="暂无消息"/>
</properties>
</profile>
<!-- 以下为WebParts的配置 -->
<webParts>
<personalization >
<providers>
<add connectionStringName="LocalSqlServer" applicationName="/" name="AspNetSqlProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider"/>
</providers>
<authorization>
<!--<allow roles="user" verbs="enterSharedScope"/>--><!--Share模式开启,不开启时可开户User模式-->
<deny roles="anonymous" verbs="modifyState"/>
<allow roles="aa,bb" verbs="modifyState"/>
</authorization>
</personalization>
</webParts>
<!-- 以下为MemberShip的配置-->
<membership defaultProvider="AspNetSqlProvider">
<providers>
<add connectionStringName="LocalSqlServer" applicationName="/" description="something about Membership" requiresUniqueEmail="false" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" enablePasswordRetrieval="false" enablePasswordReset="true" passwordFormat="Hashed" name="AspNetSqlProvider" type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>
<pages theme="Silver"><!-- 页面主题设置-->
<controls>
</controls>
</pages>
<compilation debug="true"><!--发布时设成false -->
<buildProviders>
</buildProviders>
<assemblies>
</assemblies>
</compilation>
<httpHandlers>
</httpHandlers>
<httpMoles>
</httpMoles>
<!-- 验证模式-->
<authentication mode="Forms">
<forms name="xxx.xxx.net/com" loginUrl="Login.aspx/default.aspx"></forms>
</authentication>
<!--配置网页出错信息与出错显示页面 -->
<customErrors mode="On" defaultRedirect="ErrorPage.htm"><!--mode="Off"时,出错显示错误信息,发布之前可以设置为Off,发布后设置为On,出错转到自定义的错误提示页面-->
<error statusCode="403" redirect="NoAccess.htm"/><!-- 可自己添加错误信息与错误页面-->
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>

</system.web>
<!-- 以下节点作用一个页面的访问权限,可写多个,也可去掉第一句话,在一个文件夹放webconfig对整个文件夹起作用 -->
<!--
<location path="xxx.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
-->
</configuration>

热心网友

你原来用C#做啥程序?
WEB只不过是配个IIS而已。

热心网友

编码问题,使用统一的编码就没问题了

热心网友

winform用的不是web.config,而是app.config追问呵呵,我现在就是用C#些WEB程序。用的web.config配置文件。我在里面配置了默认错误页,字符编码。但是都没效果。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com