C#中的奇数字符串操作错误... String.Format不起作用

时间:2011-02-16 13:12:00

标签: c# string viewstate

我们正在使用viewstate字符串。这个字符串的长度各不相同,如下所示:

string Viewstate = "H4sIAAAAAAAAAO09WYwcx3W1y5sixaV4WAxNuklK3F1pODs903ORoqXlHuRauzx2SN32qqend7fFme5hd83Orhj5yGEDcpA4cRzkUBADSZAfGwiUn8SIcyBAEgiwgxjIT5wPxwgQBEgcIDDgJB9xqqqvqp7unu6eniVpaAAuZ%2Fp4VfXu9%2BpV1df%2BA%2Bzq6ODI64tviRtitimqa9kb9bdkCV760rdf%2BZ0xY7I5CsBmGwDwCUMHBUlrZY2Oml0VJdnIiu12U5FEqGhqtgZFKC%2BJqrgm6wutdvOp27osX9ca8g9Xv%2FFnX89d%2FfMDGE53AuAPh1vbtKAgmG1NlVWYvbPwkiJ3lzUNomeNe%2BDTYLTLkxeeohtuytDIQnEt21GyM%2FbLy%2FIq2PXWitIo2G9eIW8%2B49%2FUOmw1s9fQnwW13YHXlEZDVsHYek3ckKfVxoymQkXtyDaoKQLqXB9Q85reAjtX0V%2F7vSp6a0esLuyRG%2BJcQ4E2hDKBMNkHwo0ORCBuy5sQ7MY44Bkk7ACCpq8haonSupxtbfmCQe8SUDdFVW5e1bVO2wJVpLuyO35Xyvb7F0lXMpiSXbG7mhUbLUXtAfQyurUkqx3SDxNEnqdHs3eQ0RRK9Gj2RRzNoqLetd6v2O9fJl15NuJoCIT9TW1N60D8Owl53V4IDk5nYjPY4Ya8KnaacEaXkcDOon82rPnYsI72wJpTG7Tg7gBn%2FGjVMSBCW0PZyM4qG2Cvsa5157WOZr9ZjPrmgXZHX5NfFnVVUdfYt8f7DGNJNgykqgwTocU82%2BtzPeqGVlLLchuN13rTkbTnI6HPIqVYR8x9UEI9mEEqkvykGSsenMcaWkMUJQbKC7GhPG7Ioi6tIyXGADIVSKYPoBrCkgRvqDJmbvC42aFZXWs3tK5qgyohUMeDtOidBRPGApRbBnisY8j6LIFi2K%2FPJejJYWdQ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fTBgWLDjl6IwLnaEujU28pqNe7zS9uZz1rla90INRUf6aEYI%2BmSk1Fuot%2FztOcSZF1JE9%2B%2FDjQaGtqjfThnd4cgcM2IEmFQKnMZwpF5yj18MZJWL27ZqFlpOZKzkfs89XXZenudBNOyBsIRs%2FJNFjEyNvM8d214OO7k5wr23vieT1KENpH4C6AE%2BfuG%2BYR9zVJa8tZfFa7GnIm9yL4hN%2FJ6oviFj4z3tlzj89UqdrXgBY8Na981a555T3brXzgG1GyLpKTAxgiysUUDkgl6SYLIUuiirx1zJiEJZuiAacJB8mN20qcncb9SJDPIDz20KBfkx6a5HmbJnl%2BIJr8P%2F6SvbiOrgAA";

如果我们使用viewstate发送postData,将该字符串硬编码到post数据中,一切正常,但是当我们执行string.format(“Viewstate = {0}”,Viewstate)时;帖子数据不起作用。似乎string.format以某种方式从视图状态中剥离了一些东西,我们无法弄明白。有没有人经历过这个?

1 个答案:

答案 0 :(得分:1)

AFAIK ASP.NET hashes the viewstate by default,并将哈希值添加到结尾。 我认为,当你硬编码它的值时,它会覆盖哈希值,当你访问它时 由财产它没有,这就是它失败的原因。