Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#插入后重定向URL从AJAX调用到处理程序_C#_Jquery - Fatal编程技术网

C#插入后重定向URL从AJAX调用到处理程序

C#插入后重定向URL从AJAX调用到处理程序,c#,jquery,C#,Jquery,我正在编写一个简单的重定向模块,它执行以下操作: ##sample URL: http://localhost/redir.aspx?r=1234## 1.-我获取URL的值,并在数据库中查询我的URL表,以检索要重定向的正确URL 2.-我使用Javascript使用Google API获取用户纬度和经度 3.-我对.ashx处理程序进行AJAX调用,将纬度和经度传递回代码背后的C#。在处理程序中,我对数据库进行了一次插入,以记录用户的纬度和经度 4.-我将用户重定向到先前从数据库检索到的正

我正在编写一个简单的重定向模块,它执行以下操作:

##sample URL: http://localhost/redir.aspx?r=1234##
1.-我获取URL的值,并在数据库中查询我的URL表,以检索要重定向的正确URL

2.-我使用Javascript使用Google API获取用户纬度和经度

3.-我对.ashx处理程序进行AJAX调用,将纬度和经度传递回代码背后的C#。在处理程序中,我对数据库进行了一次插入,以记录用户的纬度和经度

4.-我将用户重定向到先前从数据库检索到的正确URL

我有以下问题,我正在尝试找到解决方法:

redir.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
          string r = Request.QueryString["r"];
          int result = CallDatabase(r);  //This method makes a call to my database and gets some value from my table that I need to include on my javascript. After that, I use RegisterClientScriptBlock to insert Google API Javascript to get the Geolocation from the user. In the javascript I include an extra parameter (val) that I get from CallDatabase.
          if (result > 0) 
              GetUrl(result); //Now I query the DB and get the URL to do the redirection. Once I have the URL from the DB, I do a response.redirect
    }
我正在代码背后添加的Javascript代码对我的handler.ashx文件进行AJAX调用。此处理程序在数据库中插入以存储用户纬度和经度

例如:

function success(position) {
    var lat = position.coords.latitude;
    var lng = position.coords.longitude;
    var pullurl = '/handler.ashx?val=TN100&latlng=' + lat + ',' + lng;
    get(pullurl);
}

function get(url) {
    $.ajax({
        type: "GET",
    url: url,
    success: handleData
})
如果我不做重定向,一切正常。如果我执行重定向,则处理程序不执行插入。由于重定向完成得非常快,处理程序似乎没有时间进行插入。我一直在想办法解决这个问题,但我没有找到任何办法