Click here to Skip to main content
16,021,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Any one can help me how to use url ReWritting concept in asp.net button click, i have checked before application start using global.asax its working fine but the same concept i have applied button click event its getting error i don't know the reason please help me ,
C#
protected void BTNTEST_Click(object sender, EventArgs e)
{
    string CurrentURL_Path = Request.Path.ToLower();
    if (CurrentURL_Path.StartsWith("/urlrewriting/"))
    {
        CurrentURL_Path = CurrentURL_Path.Trim();
        //string NewsID = "21";// CurrentURL_Path.Substring(CurrentURL_Path.IndexOf("/"));
        HttpContext MyContext = HttpContext.Current;
        MyContext.RewritePath("/urlrewriting/test.aspx?News=21");

    }

}



its shows error like ,


XML
Server Error in '/urlrewriting' Application.
--------------------------------------------------------------------------------

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.




how to solve the issue ?
Posted

1 solution

 
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