简体   繁体   English

从Code Behind方法重定向到ASPX页面时,有什么方法可以发布值

[英]Is there any way to POST values while redirecting to an ASPX page from a Code Behind method

Is there any way to POST values while redirecting to an ASPX page from Code Behind, I can send it using a get like below 从Code Behind重定向到ASPX页面时,有什么方法可以发布值,我可以使用下面的get命令发送它

Response.Redirect("AdminRegisterTeacherEdit.aspx?messageID=" + messageID);

So, AdminRegisterTeacherEdit.aspx page retrieves the messageID, but it can be seen in the URL, I need to do it from a code behind method using POST, Please suggest me a way. 因此,AdminRegisterTeacherEdit.aspx页面检索messageID,但可以在URL中看到它,我需要使用POST方法从背后的代码中完成操作,请提出一种建议。

Use Session instead, like this: 改用Session ,如下所示:

Session["YourIDValues"] = YourListOfIDValues;

Note: Session holds objects, so you can put whatever you want in Session . 注意: Session拥有对象,因此您可以将任何内容放入Session

To retrieve the value from Session you need to do this: 要从Session获取值,您需要执行以下操作:

if(Session["YourIDValues"] != null)
{
    List<string> myListOfIDValues = Session["YourIDValues"] as List<string>;
}

Note: You must cast the object to the right type when retrieving the value from Session cache. 注意:从Session缓存中检索值时,必须将对象转换为正确的类型。

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

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