Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to 2 value from mypage.aspx.cs to filecs.ashx.

What I have tried:

int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
// int id = int.Parse((sender as LinkButton).CommandArgument);
string id =row.Cells[0].Text;
string username = Session["username"].ToString();
###i want to pass id and username to ashx

//myiframe.Attributes["src"] = ResolveUrl("~FileCS.ashx?documentid=" +id + "&username="+username+");
myiframe.Attributes["src"] = ResolveUrl("~/FileCS.ashx?documentid=" + id);
Posted
Updated 9-Mar-20 9:31am
v2
Comments
DerekT-P 8-Mar-20 15:40pm    
So what is your question? You've told us what you want to do, you've told us what you've tried, but what is not working?
Member 3989541 31-Oct-20 4:11am    
session option work for me

1 solution

In the calling page:
C#
myiframe.Attributes["src"] = ResolveUrl("~/FileCS.ashx?documentid=" + HttpUtility.UrlEncode(id) + "&username=" + HttpUtility.UrlEncode(username));
In the handler:
C#
string id = context.Request.QueryString["documentid"];
string username = context.Request.QueryString["username"];
Although, since the username comes from the session, you could just as easily access the session from the handler; you'd just need to implement the IReadOnlySessionState interface[^]:
C#
public class LoadPdfFileHandler : IHttpHandler, IReadOnlySessionState
{
    public bool IsResuable => false;
    
    public void ProcessRequest(HttpContext context)
    {
        string id = context.Request.QueryString["id"];
        string username = Convert.ToString(context.Session["username"]);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900