ScriptResource error: am I being hacked?

前端 未结 1 488
广开言路
广开言路 2021-02-09 04:58

I keep getting errors like this on one of my sites. It tends to happen randomly throughout the day any for periods in the night when I would not expect users on the site.

相关标签:
1条回答
  • 2021-02-09 05:02

    I believe this error is caused by your ViewState being decrypted using an out-of-date ViewStateUserKey.

    Removing these errors is a two-step process:

    1. Ensure you have a site-specific validation key. You can use several online resources to generate one for you, such as this one.
    2. Ensure the page's ViewStateUserKey is always consistent. From the MSDN documentation:

    Setting the ViewStateUserKey property can help you prevent attacks on your application from malicious users. It does this by allowing you to assign an identifier to the view-state variable for individual users so that they cannot use the variable to generate an attack. You can set this property to any string value, such as the user's session ID or the user's authenticated name.

    You can do this by setting it yourself (perhaps in your Page or base Page's Init event):

    if (Session["ViewStateUserKey"] == null)
    {
        Session["ViewStateUserKey"] = new Guid().ToString();
    }    
    this.Page.ViewStateUserKey = Session["ViewStateUserKey"].ToString();
    

    And no, I don't think you're being hacked.

    0 讨论(0)
提交回复
热议问题