简体   繁体   English

JQuery $ .post在VS 2010实例中工作,但在IIS 7.5中部署时则不行

[英]JQuery $.post works in VS 2010 instance but not when I deploy in IIS 7.5

I have checked the url in $.Post, it's fine. 我已经检查了$ .Post中的网址,没关系。 I have also checked the connectionstring. 我还检查了连接字符串。 Everything works great in the entire website including $.ajax commands except one $.post command. 除了一个$ .post命令外,整个网站的所有功能都很好,包括$ .ajax命令。 I keep getting "error while saving record" message. 我一直收到“保存记录时出错”的消息。

Code I have is that on a jquery dialog box's Save button: 我的代码是在jquery对话框的Save按钮上:

var post = $.post(url,
                        $("#myview").serialize(),
                        function () {
                            thisDialog.dialog("close");
                        });
                        post.error(function (xhr, ajaxOptions, thrownError) {
            alert("Error while saving the record");

This works in local VS instance when I run in debug mode but it doesn't run when I deploy the website to IIS 7.5. 当我在调试模式下运行时,这适用于本地VS实例,但是当我将网站部署到IIS 7.5时,它不会运行。 Can someone please guide what the issue can be? 有人可以指导问题是什么吗? All dlls are present, url is fine too 所有的dll都存在,网址也很好

url is: Home/Start 网址是:主页/开始

[HttpPost]
    public ActionResult Start(StartModel model, FormCollection collection)
            {
                try
                {
                    Service.Create(model);
                    return RedirectToAction("List");
                }

this works in VS but not in IIS 7.5 这适用于VS但不适用于IIS 7.5

I get error code 500 我收到错误代码500

Stack trace shows error message: SqlDateTime overflow. 堆栈跟踪显示错误消息:SqlDateTime溢出。 Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM 必须在1/1/1753 12:00:00 AM和12/31/9999 11:59:59 PM之间

i am setting the date value using jquery date control. 我使用jquery日期控件设置日期值。 any guidance is appreciate. 任何指导都很感激。

Have you try to capture the http request via your navigator's developer tool ? 您是否尝试通过导航器的开发人员工具捕获http请求? do you see the request and what is the response from the server ? 你看到了请求以及服务器的响应是什么?

Set customErrors mode to "off" (in your web.config) and then investigate response in firebug, you should see nice stack trace returned from the server. 将customErrors模式设置为“off”(在web.config中),然后调查firebug中的响应,您应该看到从服务器返回的良好堆栈跟踪。 Just make sure that your catch block (which you didn't post) looks like: 只要确保你的catch块(你没有发布)看起来像:

try
{
// your code here
}
catch(Exception ex)
{
 throw;
}

(Make sure that you are not doing throw ex; because that way you will lose stack trace). (确保你没有抛出ex;因为这样你将失去堆栈跟踪)。

You can continue from there. 你可以从那里继续。

As a blind guess it might happen that: 1. Service.Create(model); 盲目猜测可能会发生:1。Service.Create(model); fails (perhaps you don't have perimissions from that machine to access "Service", or 2. It might happen that you are posting too much data, so try increasing maxRequest length in 失败(也许你没有从该机器获得访问“服务”的权限,或者2.你可能会发布过多的数据,所以尝试增加maxRequest的长度

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="102400" executionTimeout="1200" />
    </system.web>
</configuration>

It would be useful to know your stack trace, though. 但是,了解堆栈跟踪会很有用。

Without changing anything in your current setup, it may just be an error in the date format. 如果不更改当前设置中的任何内容,则可能只是日期格式中的错误。 Instead of setting the date as 1/2/2011 through the calendar control, try setting it as 1/2/2011 12:00:00 PM 不要通过日历控件将日期设置为1/2/2011而是尝试将其设置为1/2/2011 12:00:00 PM

Or reset datepicker dateFormat (other formats here ): 或者重置datepicker dateFormat( 这里的其他格式):

.datepicker({
    dateFormat: 'mm/dd/yy'
});

Without more info I am just taking a shot in the dark here, but it may be that you're using a relative URL, for example /bob/fred , and the server has a different file structure to your local application. 没有更多的信息我只是在黑暗中拍摄,但可能是你正在使用相对URL,例如/bob/fred ,并且服务器具有与本地应用程序不同的文件结构。

Lets suppose that your app is in the following structure: 让我们假设您的应用程序采用以下结构:

/bob/fred <- the directory you're accessing in the $.post call
/jim/index.aspx <- the page you're calling $.post in

And when you put it on the server the file structure, from the application root, is like this: 当你把它放在服务器上时,应用程序根目录中的文件结构是这样的:

/site/bob/fred
/site/jim/index.aspx

When running the app through VS 2010 this would be correct. 通过VS 2010运行应用程序时,这是正确的。 However on the server it would require a different URL. 但是在服务器上它需要一个不同的URL。

The next step should be checking the $.post call using Firebug - see if you're getting a 404. If so, the above info should help. 下一步应该是使用Firebug检查$ .post调用 - 看看你是否得到了404.如果是这样,上面的信息应该会有所帮助。 If not, please post some more code. 如果没有,请发布更多代码。

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

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