How to refresh the current page with a specific request value (C #)

I had a problem with a simple error notification when uninstalling a specific product.

I have one page products.aspx I have 2 categories - Mobile (cat 1) - Net (cat 2)

When I delete a certain product from a certain category, I get a notification “your product has been deleted ...”, and then after 2 seconds I want to refresh the current page, therefore a new and correct number of products. My problem is that I request a querystring "deleteid" when deleting a product, and then my query with a "category" of course is 0. In general, I need "products.aspx? Categoryid = 2" to update, but categoryid has value 0 when "deleteid" is requested.

I still have it, I hope you understand and can help me ... Thank you!

... listing products by category (Request.QueryString["categoryid"])
... Then deleting by id, (Request.QueryString["deleteid"])    
... and now my problem and what I have so far:

var query = Request.QueryString["deleteid"];
    if (query.HasValue())
    {
        // deleting product
        DeleteSpecificProduct(query.Int16());

        errornotification.Text += @"Your product has been deleted";

        // refreshing current page
        var categoryid = Request.QueryString["categoryid"].Int16();
        var url = String.Format("products.aspx?categoryid={0}", categoryid);
        Response.AppendHeader("REFRESH", "2;URL=" + url);
     }

//Thank

+3
source share
2 answers

Delete links have categoryid. For instance:

<a href="products.aspx?deleteid=1&categoryid=1234">Delete Product 1</a>

, URL- , , .

, , , http. <head>

<meta http-equiv="Refresh" content="2; URL=..." />
0

Response.Redirect(String.Format("products.aspx?categoryid={0}", categoryid)) ?

0

Source: https://habr.com/ru/post/1793372/


All Articles