簡體   English   中英

在IIS 7.0中發布MVC 3.0站點

[英]Publish MVC 3.0 Site in IIS 7.0

我使用MVC 3.0編程網站,該網站使用EntityFrame work 4.0,在控制器層中,我具有以下功能:

  public ViewResult Index()
    {
     return View(_DatabaseSMSEntities.People.ToList());
    }

在視圖層中,我使用了Telerik Grid:

<% Html.Telerik().Grid<ProjectWebsite.Models.People>(Model)
                    .Name("People")
                    .Columns(columns =>
                    {
                        columns.Bound(o => o.PersonID).Format(
                         "<a href='../WebPage/PersonSMSPage.aspx?personID=" + "{0}" + @"' <br/>runat=""server"">" +
                         "<img src='../../Content/themes/base/images/RegisterSMS.png' <br/>alt='{0}' />"<br/>
                        );                                           

                    })
                    .RowAction(row =>
                    {
                        if (row.Index == 0)
                        { row.DetailRow.Expanded = false; }
                    })                   
                     .Render();%>

我在IIS 7.0中發布了它。 但這行不通。

<connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
    <add name="DatabaseSMSEntities" connectionString="metadata=res://*/Models.ModelDatabaseSMS.csdl|res://*/Models.ModelDatabaseSMS.ssdl|res://*/Models.ModelDatabaseSMS.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DatabaseSMS.mdf;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
    <add name="cn1" connectionString="data source=~/ErrorsLog/Errors.db" />
  </connectionStrings>

首先,我將其發布在D:\\ Pardis中,但出現錯誤:

   CREATE DATABASE permission denied in database 'master'.
    An attempt to attach an auto-named database for file D:\Pardis\App_Data\DatabaseSMS.mdf failed. A database with the same name
exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
An attempt to attach an auto-named database for file D:\Pardis\App_Data\DatabaseSMS.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

Source Error: 


Line 20:         public ViewResult Index()
Line 21:         {
Line 22:             return View(_DatabaseSMSEntities.People.ToList());
Line 23:         }
Line 24: 

然后,我在Inetup中發布了它,但出現錯誤。 我在用戶列表中沒有ASPNET用戶來設置安全性。

可能有兩個問題

  1. 您忘記復制數據庫文件(如果使用的是SQL Server Compact)
  2. 您正在通過代碼創建一個新的數據庫。 您不應在部署環境中創建數據庫。 如果您正在使用,可能會發生這種情況

    System.Data.Entity.Database.SetInitializer( 一些策略

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM