简体   繁体   English

在IIS 7.0中发布MVC 3.0站点

[英]Publish MVC 3.0 Site in IIS 7.0

I program website with MVC 3.0 which uses EntityFrame work 4.0, In controller layer I Have this: 我使用MVC 3.0编程网站,该网站使用EntityFrame work 4.0,在控制器层中,我具有以下功能:

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

And in View Layer I used Telerik Grid: 在视图层中,我使用了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();%>

I published it in IIS 7.0. 我在IIS 7.0中发布了它。 But it does not work. 但这行不通。

<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>

First, I published it in D:\\Pardis, But I got error: 首先,我将其发布在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: 

Then, I published it in Inetup but I got error. 然后,我在Inetup中发布了它,但出现错误。 I do not have ASPNET user in user list to set security. 我在用户列表中没有ASPNET用户来设置安全性。

There might be two problems 可能有两个问题

  1. You forgot to copy your database file (If you are using sql server compact) 您忘记复制数据库文件(如果使用的是SQL Server Compact)
  2. You are creating a new database through code. 您正在通过代码创建一个新的数据库。 You should not be creating databases in your deployment environment. 您不应在部署环境中创建数据库。 This can probably happen if you are using 如果您正在使用,可能会发生这种情况

    System.Data.Entity.Database.SetInitializer( some strategy ) System.Data.Entity.Database.SetInitializer( 一些策略

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM