我们在在线服务器上发布网站时如何配置web.config文件? [英] How to configure web.config file when we publish the website on the online server?

查看:332
本文介绍了我们在在线服务器上发布网站时如何配置web.config文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发布了一个网站,但是当我输入我的网页的URL时,我在搜索阶段出错,那么我得到了500个内部服务器错误,所以我必须在我的web.conf文件或其他位置进行更改。< br $> b $ b

我尝试过:



 <?  xml    版本  =  1.0   编码  =  utf -8    >  
< configuration >
< system.web >
< httpRuntime

< span class =code-attribute> executionTimeout = 90

maxRequestLength = 4096

useFullyQualifiedRedirectUrl = false

minFreeThreads = 8

minLocalRequestFreeThreads = 4

appRequestQueueLimit = 100

< span class =code-attribute> enableVersionHeader = true

/ > ;
< 配置 >
< connectionstrings >
< add 名称 = astha connectionString = 数据源= 208.91.198.196;用户ID = aastha;密码= aa12 @ stha143 @; 提供商 = SQLOLEDB; providerName = System.Data.SqlClient / >
< add < span class =code-attribute> name = Excel03ConString connectionString = Provider = Microsoft.Jet.OLEDB.4.0; Data Source = {0}; Extended Properties ='Excel 8.0; HDR = YES' / >
< < span class =code-leadattribute> add name = Excel07ConString connectionString = Provider = Microsoft.ACE.OLEDB.12.0; Data Source = {0}; Extended Properties ='Excel 8.0; HDR = YES' / >
< < span class =code-leadattribute> add name = asthaEntities connectionString = metadata = res://*/App_Code.astha.csdl | res:// * / App_Code.astha.ssdl |资源://*/App_Code.astha.msl;供应商= System.Data .SqlClient;提供者连接字符串= 数据 来源 = ADMIN-PC\SQLExpress;初始 目录 = astha;集成 安全性 = True; MultipleActiveResultSets = True providerName = System.Data.EntityClient / < span class =code-keyword>>
< 编译

defaultLanguage = c#

< span class =code-attribute> debug = true

< span class =code-attribute> / >
< customErrors

< span class =code-attribute> mode = RemoteOnly

/ >
< 程序集 >
< add assembly = System.Security,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = B03F5F7F11D50A3A < span class =code-attribute> / >
< add 汇编 = System.Data.Entity,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = B77A5C561934E089 / >
< add assembly = System.Data.Entity.Design,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = B77A5C561934E089 / >
< 身份验证 mode = Windows / >
< 授权 >
< allow users = * / < span class =code-keyword>>
<! - 允许所有用户 - >
<! - < allow users =[逗号分隔的用户列表]
roles =[逗号分隔角色列表]/>
< deny users =[逗号分隔的用户列表]
roles =[逗号分隔的角色列表]/>
- >

< trace

< span class =code-attribute> 已启用 = false

requestLimit = 10

pageOutput = false

traceMode = SortByTime

localOnly = true

/ >
< sessionState < span class =code-attribute>

< span class =code-attribute> mode = InProc

stateConnectionString = tcpip = 127.0.0.1:42424

< span class =code-attribute> sqlConnectionString = 数据源= 127.0.0.1; Trusted_Connection = yes

cookieless = false

< span class =code-attribute> timeout = 20

/ >
< 全球化

requestEncoding = utf-8

< span class =code-attribute> responseEncoding = utf-8

/ > ;

解决方案





通常没有服务器和本地计算机之间的web.config中的配置不同。除了数据库连接..

此错误500-内部服务器错误,不显示您的服务器发生了什么。

求助你,在web.config中添加以下行。

服务器将显示错误的确切内容。有了这个错误,你就会有正确的habillity。



 <   system.web  >  

< 身份验证 mode = Windows / >

<! - 在您的WEB.CONFIG中添加此代码错误 - >
<! -
<的customErrors>如果/在执行请求期间发生未处理的错误
时,该部分启用配置
。具体来说,
它使开发人员能够配置html错误页面
来代替错误堆栈跟踪。
- >


< customErrors mode = defaultRedirect = GenericErrorPage.htm >
< 错误 statusCode = 403 重定向 = NoAccess.htm / >
< 错误 statusCode = 404 重定向 = FileNotFound.htm / >
< / customErrors >

<! - END THE代码错误 - >

< 授权 >

< / system.web >


I publish one website but I got an error on searching stage when I enter a URL of my pages then I got 500- internal server error so what I have to make changes in my web.conf file or in other location.

What I have tried:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
		<httpRuntime 

         executionTimeout="90" 

         maxRequestLength="4096" 

         useFullyQualifiedRedirectUrl="false" 

         minFreeThreads="8" 

         minLocalRequestFreeThreads="4" 

         appRequestQueueLimit="100" 

         enableVersionHeader="true"

		/>
<configuration>
  <connectionstrings>
    <add name="astha" connectionString="Data Source=208.91.198.196;User Id=aastha;Password=aa12@stha143@;" Provider=sqloledb; providerName="System.Data.SqlClient" />
    <add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'" />
    <add name="Excel07ConString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'" />
    <add name="asthaEntities" connectionString="metadata=res://*/App_Code.astha.csdl|res://*/App_Code.astha.ssdl|res://*/App_Code.astha.msl;provider=System.Data.SqlClient;provider connection string="Data Source=ADMIN-PC\SQLExpress;Initial Catalog=astha;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
    <compilation 

         defaultLanguage="c#"

         debug="true"

    />
    <customErrors 

    mode="RemoteOnly" 

    /> 
<assemblies>
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <authentication mode="Windows" /> 
    <authorization>
        <allow users="*" /> <!-- Allow all users -->
            <!--  <allow     users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny      users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
    <trace

        enabled="false"

        requestLimit="10"

        pageOutput="false"

        traceMode="SortByTime"

		localOnly="true"

    />
    <sessionState 

            mode="InProc"

            stateConnectionString="tcpip=127.0.0.1:42424"

            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"

            cookieless="false" 

            timeout="20" 

    />
    <globalization 

            requestEncoding="utf-8" 

            responseEncoding="utf-8" 

   />

解决方案

Hi,

Normally there aren't different configuration in the web.config between server and local machine. Except database connection..
This error "500- internal server error", don't show what's happen with your server.
For help you, add the lines below in your web.config.
The server will show what exactly the error is. With the error you will have habillity for correct.

<system.web>

<authentication mode="Windows" /> 

<!-- ADD THIS CODE ERROR IN YOUR WEB.CONFIG-->
<!--
            The <customErrors> section enables configuration 
            of what to do if/when an unhandled error occurs 
            during the execution of a request. Specifically, 
            it enables developers to configure html error pages 
             to be displayed in place of a error stack trace.
 -->

<customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
    <error statusCode="403" redirect="NoAccess.htm"/>
    <error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>

<!-- END THE CODE ERROR -->

<authorization>

</system.web>


这篇关于我们在在线服务器上发布网站时如何配置web.config文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆