c# - 在通用处理程序中接收 HTTP Post 时如何异步刷新主页?

标签 c# asp.net http asynchronous

我正在开发一个 ASP.Net webform 应用程序,它使用通用处理程序来接收 HTTP POST 并从中检索数据,以便将它们写入数据库,然后将其显示在主页的 GridView 控件中。我想让主页在通用处理程序收到 HTTP Post 后自动刷新,但它不能,我必须单击浏览器上的刷新按钮来更新其数据内容。我试着像这样在 ProcessRequest 方法中编写一些令人耳目一新的代码:

public void ProcessRequest(HttpContext context)
{
    //Parse and process data from received HTTP Post
    context.Response.Redirect("~/Main.aspx");
}

但它不起作用。我怎样才能做到?

最佳答案

context.Response.Redirect("~/Main.aspx?userid=1234&pagestate=5", false);

Page_Load(object sender, EventArgs e)
{
     int userid = Request.QueryString["userid"];
     int pagestate = Request.QueryString["pagestate"];

     if(user != 0 && pagestate == 5)
     {
         //configure page for the reloaded state ie. once you reload it with this variable, how is it different to without this variable.
     }
}

使用查询字符串值来确定需要如何设置页面。传递“ProcessRequest”使用的信息并围绕这些值加载页面。

我有一个类似的问题...我通过执行您上面所做的并包含一个查询字符串变量或 2 来将页面状态设置为所需的状态来解决它。

关于c# - 在通用处理程序中接收 HTTP Post 时如何异步刷新主页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32941075/

相关文章:

c# - 尝试全局启用 CORS 时出现异常

c# - 实例化和接口(interface)

c# - MVC3如何更新多个项目的库存

c# - 如何找到哪个标签页(TabControl)在

asp.net - 将 SQL server 2008 用于 ASP.net 2.0 Membership provider

c# - IIS 保存 Word 文档的权限

.htaccess - 没有遵循重定向

java - 处理响应代码 : 403 for URL with clojure enlive

http - 在 Golang 中转换 curl 请求并将文件作为有效负载的一部分发送

c# - Lambda 检查列表是否包含所有属性的某些属性值