我有一个Web项目(C#Asp.Net,EF 4,MS SQL 2008和IIS 7),我需要在本地将它迁移到IIS 7(目前可以正常使用CASSINI).
在IIS的本地我Default Web Site
有我的部署.我的部署和Default Web Site
在池上的ASP.NET v4.0(查看设置图像)池目标框架4作为我的web项目.
访问该站点时,浏览器不会显示该页面,而是允许浏览器下载该页面.
我在本地IIS上运行其他项目,它们没有问题(但它们不使用实体框架).
使用事件记录器我看到如下错误:
Exception information:
Exception type: EntityException
Exception message: The underlying provider failed on Open.
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
Run Code Online (Sandbox Code Playgroud)
更新:您可以在此问题的资源中读取必须在MS …
我得到这种错误像::
指定的参数超出了有效值的范围.参数名称:site
调试我的任何项目时.
我在重新安装My Visual Studio 2012之后也尝试过.但是在调试时我又遇到了同样的问题.
我的系统配置是:
显示Web Page Like时抛出异常,
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site]
System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +298
[HttpException (0x80004005): Specified argument was out of the range of valid values.
Parameter name: site]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Run Code Online (Sandbox Code Playgroud) 如何从web.config
文件中读取连接字符串到类库中包含的公共类?
我试过了:
WebConfigurationManager
ConfigurationManager
Run Code Online (Sandbox Code Playgroud)
但是这些类在我的类库中无法识别.
是否可以转换以下Web.config appSettings文件:
<appSettings>
<add key="developmentModeUserId" value="00297022" />
<add key="developmentMode" value="true" />
/* other settings here that should stay */
</appSettings>
Run Code Online (Sandbox Code Playgroud)
进入这样的事情:
<appSettings>
<add key="developmentMode" value="false" />
/* other settings here that should stay */
</appSettings>
Run Code Online (Sandbox Code Playgroud)
所以,我需要删除关键的developmentModeUserId,我需要替换关键developmentMode的值.
我搜索了Google和StackOverflow试图找到解决方案,但它们似乎都与ASP.NET等有关.
我通常在我的服务器上运行Linux,但是对于这个客户端,我使用Windows与IIS 7.5(和Plesk 10).这就是为什么我对IIS和web.config文件略有不熟悉的原因.在.htaccess
文件中,您可以使用重写条件来检测协议是否为HTTPS并相应地重定向.有没有一种简单的方法可以使用web.config文件实现这一点,甚至使用我安装的" URL Rewrite "模块?
我没有使用ASP.NET的经验,所以如果这涉及到解决方案,那么请包括如何实现的明确步骤.
我使用web.config而不是 PHP 执行此操作的原因是我想在站点内的所有资产上强制使用HTTPS.
我在配置文件中有一个带有值的C#程序.我想要的是存储&符号的网址值,如...
<appSettings>
<add key="myurl" value="http://www.myurl.com?&cid=&sid="/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
但是我在构建我的网站时遇到错误.不允许使用&符号.我尝试了各种形式的逃避&符号无济于事.有人知道这样做的正确形式吗?欢迎所有建议.
每次我必须使用IIS7为ASP.NET添加处理程序或模块时,指令总是告诉我将它合并为两个部分:system.web
和system.webserver
.
<system.web>
<httpHandlers>
</httpHandlers>
<httpModules>
</httpModules>
</system.web>
Run Code Online (Sandbox Code Playgroud)
还有这个:
<system.webServer>
<modules>
</modules>
<handlers>
</handlers>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
这两个部分有什么区别?
此外,如果我不将它添加到该system.web
部分,我的Visual Studio 2008调试器也无法正常工作.
我需要在ASP.NET应用程序中使用不同的数据库连接字符串和SMTP服务器地址,具体取决于它是在开发环境还是生产环境中运行.
应用程序通过WebConfigurationManager.AppSettings属性从Web.config文件中读取设置.
我使用Build/Publish命令通过FTP将应用程序部署到生产服务器,然后用正确的方法手动替换远程Web.config.
有可能以某种方式简化部署过程吗?谢谢!
在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的.
我的/ portal /目录中所有aspx页面的顶行都有此错误消息,我知道这是一个常见的错误消息.我已经用Google搜索了这个错误信息,我看到很多帖子告诉我将/ portal /文件夹配置为IIS中的应用程序(我有),还有更多帖子告诉我我已经嵌套了web.configs(但是没有任何帖子提供解决方案的指导).
我的设置是我的根目录中有一个web.config,然后我正在尝试在/ portal /目录中创建一个公司门户./ portal /目录有自己的(必要的)web.config.
我的web.config第50行是这样的:
<customErrors mode="Off" defaultRedirect="customerrorpage.aspx"/>
<anonymousIdentification enabled="true"/>
<authentication mode="Forms"/>
<membership defaultProvider="MyProvider">
Run Code Online (Sandbox Code Playgroud)
所以我有domain.com/web.config和domain.com/portal/web.config ...所以我的domain.com/portal/default.aspx页面将无法加载.
这是什么真正的解决方案?我以某种方式找到一种方法将我的根web.config与我的/ portal /目录web.config合并,还是我离开这里?
任何指导将不胜感激!
在web.config
ASP.NET应用程序的-file中,配置的某些部分(如appSettings
和connectionStrings
)支持属性file
和configSource
.
使用file
-attribute和configSource
-attribute有什么区别?什么时候应该使用哪个属性,你可以同时使用它们吗?
<?xml version="1.0"?>
<configuration>
<appSettings file="AppSettings.config">
</appSettings>
<connectionStrings configSource="ConnectionStrings.config">
</connectionStrings>
<!-- ... -->
</configuration>
Run Code Online (Sandbox Code Playgroud)