0

我的项目在运行 Visual Studio 2010 (SP1) WebServer 的计算机上运行良好

发布到服务器时,所有问题都像往常一样

服务器是:windows2003

我认为它之前没有在其他项目中尝试过运行 Ef

所以一开始我有很多关于引用的错误,虽然我已经设法克服了这些错误,最后当项目中的所有内容都设置好并且我看到页面而不是调试错误时......并且表单正在显示,只要我提交,

当我发布表单(使用 jQuery/Ajax POST)时,我得到500 internal server error

甚至不知道问题是什么

包装SaveChanges()Try Catch返回 500 内部服务器错误

同样,在本地一切都很好,但在发布到服务器时却不行

而且最近项目的唯一变化是这个使用实体框架

使用语句

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using HtTakalotModel;
//and this last one was added only to try get more info on the error 
using System.Data.Entity.Validation;

[WebMethod]
public static string SendCfrm(object SentPars)
{
    string newLinw = Environment.NewLine;
    var formValues =(Array) SentPars;
    string cName = "", cPhone = "", cMail = "", cUrgency = "", cComments = "";
    int cLocalSnif = 0;
    string RecordsEfected = "";
    Dictionary<string, string> MainDataDict = new Dictionary<string, string>();
    foreach (Dictionary<string, object> pair in formValues)
    {

        cName = (string)((object[])pair["value"])[0];
        cMail = (string)((object[])pair["value"])[1];
        cPhone = (string)((object[])pair["value"])[2];
        cUrgency = (string)((object[])pair["value"])[3];
        cLocalSnif = ((object[])pair["value"])[4].ToString().ToInt();
        cComments = (string)((object[])pair["value"])[5];
    }
    try
    {
        using (var dbTakalot = new HtTakalotEntities())
        {
            var NewTakala = new tblHtTakalot()
            {
                ClientName = cName,
                ClientPhone = cPhone,
                ClientMail = cMail,
                Urgency = cUrgency,
                LocalSnif = cLocalSnif,
                CreationDate = DateTime.Now,
                TakalaDesc = cComments

            };
            dbTakalot.tblHtTakalot.AddObject(NewTakala);
            RecordsEfected = dbTakalot.SaveChanges().ToString();
        }
    }
    catch (DbEntityValidationException e)
    {
        return e.ToString();
    }
    if (RecordsEfected != "1")
        return "noGo";
    return RecordsEfected;
  }
}

也......附注:在我的本地机器上我正在运行

localhost\projectName\...

在服务器上,我的项目只是 iis 中的一个文件夹

所以层次结构是

  inetPub\wwwroot\App_Code 
  inetPub\wwwroot\MyProjectName\App_Code

web.config等相同

我想这很常见

我的主要怀疑是最初在服务器中没有正确配置某些东西以便能够运行实体框架

我的 ef 版本是通过 NuGet 下载的(所以它是 V.5)

我的项目和服务器上的两个框架都设置为 4.0

我必须在服务器上进行任何预安装可能有什么问题?

我是否必须确保是否有 .net 框架版本(sub 4.x...更新)来支持 ef ?

请在这里帮助我,我正在努力解决这个问题已经 3 个小时了

更新

在更改 try Catch 以捕获 Exception insted 之后 DbEntityValidationException

错误是

System.Data.UpdateException:更新条目时出错。有关详细信息,请参阅内部异常。---> System.ArgumentException:正在使用的 SQL Server 版本不支持数据类型“datetime2”。在 System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream ,布尔异步)在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,布尔 returnStream,字符串方法,DbAsyncResult 结果)在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior runBehavior,2 identifierValues, List1 generateValues) 在 System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter 适配器) --- 内部异常堆栈跟踪结束 --- 在 System.Data.Mapping.Update.Internal.UpdateTranslator.Update (IEntityStateManager stateManager, IEntityAdapter 适配器) 在 System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache) 在 System.Data.Objects.ObjectContext.SaveChanges(SaveOptions 选项) 在 System.Data.Objects.ObjectContext.SaveChanges() 在 HtTakalot_HtTakalotForm。 c:\Inetpub\wwwroot\sell\HtTakalot\HtTakalotForm.aspx.cs:line 56 中的 SendCfrm(Object SentPars)

4

1 回答 1

0

请检查您的配置是否有效。500 表示你的 asp.net 配置无效。尝试在 Microsoft.NET 目录 aspnet_regiis.exe -i 中通过命令模式注册 asp.net,并且您是否在服务器上安装了 ajax 工具包或在服务器上复制了工具包 dll。

您可以在此处查看不同的服务器代码。 http://support.microsoft.com/kb/943891

问候,

于 2013-07-23T10:52:31.527 回答