我将尽力保持简短。
我在visual studio 2010中创建了一个非常简单的asp.net网站。我在一个连接到亚马逊RDS数据库的特定页面上有一个简单的代码。
当我在本地计算机上运行此网站时,它可以很好地从数据库中提取数据。但是当我通过1and1.com将文件放到microsoft webhost服务器上时,我得到了大量的错误消息。
我的网站www.kellendenny.com/Default.aspx加载正常。如果你必须www.kellendenny.com/Styles/WebForm1.aspx,你应该看到我正在谈论的错误。
我不明白为什么代码可以在本地计算机上运行,但不能从webhost运行。
感谢您的时间。
下面的是WebForm1.aspx页面的代码。
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.Styles.WebForm1" %>
<%@ Register assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI.DataVisualization.Charting" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Data</h2>
<meta http-equiv="Refresh" content="4" />
<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1"
Width="900px">
<series>
<asp:Series ChartType="Line" Name="Series1" XValueMember="DateTime"
YValueMembers="Voltage">
</asp:Series>
</series>
<chartareas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</chartareas>
</asp:Chart>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:db2ConnectionString %>"
SelectCommand="SELECT [DateTime], [Voltage] FROM [Table1]">
</asp:SqlDataSource>
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="DateTime" HeaderText="DateTime"
SortExpression="DateTime" />
<asp:BoundField DataField="Voltage" HeaderText="Voltage"
SortExpression="Voltage" />
</Columns>
</asp:GridView>
</asp:Content>
这是web.config文件的代码
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
</appSettings>
<connectionStrings>
<add name="db2ConnectionString" connectionString="Data Source=testdevelopment.cwroskb2ogi8.us-west-2.rds.amazonaws.com,1433;Initial Catalog=db2;Persist Security Info=True;User ID=XXXXX;Password=XXXXXXXXXXX"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off"/>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
</configuration>
答案 0 :(得分:1)
基于您能够从本地网络上的本地计算机连接到AWS RDS的事实。这表明您的连接字符串确实是正确的。
由于在部署代码时出现问题,我认为托管服务提供商可能阻止或要求打开/应用防火墙规则。这可以通过支持查询或通过1and1.com上的站点控制面板实现