【发布时间】:2017-04-08 15:07:26
【问题描述】:
我一直在尝试将我的 asp.net 应用程序上传到 godaddy 持续 3 周。我已经用web.config 解决了各种噩梦,我终于得到了至少该死的东西出现了。但是所有调用数据库信息的页面都会崩溃。我将简要介绍一下我用来使其在当前级别工作的步骤,以防我错过了除了我怀疑是当前问题之外的任何内容,即在 godaddy 数据库上没有数据库信息。
要将这个怪物上传到 Godaddy I(使用本指南和许多其他人 http://www.c-sharpcorner.com/article/how-to-host-your-asp-net-mvc-website-on-godaddy-server/)
通过在本地发布然后压缩,然后上传到 Godaddy 中站点的根目录来上传我的 Web 应用程序。然后解压到文件管理器中的那个目录(而不是使用ftp)
确保我的发布(在步骤 1 中)发布了所有 dll 和程序集(已部署 bin)
配置为
web.config完全信任级别,并设置自定义错误模式在 Goddaddy 上创建了一个 SQL Server 数据库,并将连接字符串放入
web.config(我知道该字符串有效,因为我在 Visual Studio 中测试了连接)。在
web.config我删除了system.codedom之间的所有内容(在这一步之前网站甚至没有出现)。
如果有人感兴趣,这是我的web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source= (LocalDb)\MSSQLLocalDB;AttachDbFilename="|DataDirectory|\aspnet-BA Portal- 20170128030249.mdf";Initial Catalog="aspnet-BA Portal- 20170128030249";Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="SampleConnectionString"
connectionString="Data Source= (LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Sample.mdf;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="my_banaturalportal"
connectionString="Data Source=184.168.194.53;Integrated Security=False;database=my_banaturalportal;User ID=my_banaturalportal_user;Password=*******;Connect Timeout=1500;" />
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<trust level="Full" />
<authentication mode="None" />
<compilation targetFramework="4.5.2" defaultLanguage="c#" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking"
type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0"
newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0"
newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0"
newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="itextsharp" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.10.0" newVersion="5.5.10.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="itextsharp.xmlworker" publicKeyToken="8354ae6d2174ddca" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.5.10.0" newVersion="5.5.10.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient"
type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.codedom>
</system.codedom>
</configuration>
<!--ProjectGuid: {9AFE5866-CFA2-43B2-8122-EC12418E7D63}-->
现在我有了我的网络应用程序,它至少显示出来了,但我无法登录 (https://my.banaturalportal.com/)。因此,为了更好地理解问题,我在此处 (http://testing.banaturalportal.com/) 上传了没有授权(没有登录)的第二个版本,并注意到每个调用数据库项的页面都会引发异常(调用“禁止”错误页面)。顺便说一句,网站现在没有证书。不知道有没有问题。
我从未将数据放入 SQL Server 数据库中。我以为它会以某种方式起作用。我想这是错误的。我想我的第一个问题是,当数据库项目被调用时这是否会引发异常听起来像是一个错误,因为我没有将我的数据库对象放入 Godaddy SQL Server(不知何故),即使我确保所有 .mdf即使在上传的管理器中,仍然在App_data 文件夹中。第二,如果是这种情况,我该如何将这些数据库放入godaddy?如何将我可以在我的App_data 本地访问的.mdf 文件放入godaddy,以便我的asp.net 网站可以使用它。
我进行了很多研究,但我无法真正弄清楚这些步骤是什么。我能弄清楚的是我需要 SSMS(我已经下载了),也许还有我的用于 Visual Studio 的 SQL(我也已经下载了)。
我也很乐意被指出正确的方向。我知道 Godaddy 不是一个受欢迎的话题,但我会很感激任何帮助,因为我已经每天这样做了 3 周,我就像,在这一点上非常难过。
【问题讨论】:
-
你的godaddy账号支持LocalDB吗?一个快速的谷歌表明他们没有。 stackoverflow.com/questions/38555321/… 。您可能必须将数据库导出为脚本,或将其转换为 .bak,然后将其导入您通过该帐户获得的标准 SQL Server 数据库。除了这样做和更改连接字符串之外,您所有的实际 SQL 代码等都应该可以正常工作。
-
谢谢。这对我来说是一个很好的起点。我会尝试将我的数据库导出为脚本。
标签: asp.net sql-server web-hosting