Как получить переменную "Guid" из заголовка http в ASP.NET - PullRequest
0 голосов
/ 29 января 2009

Следующая строка выдает ошибку (невозможно преобразовать тип "string" в "System.Guid")

userId = Request.QueryString["id"];

есть ли решение передать переменную Guid в заголовок http Get?

1 Ответ

3 голосов
/ 29 января 2009
try {
    userId = new Guid(Request.QueryString["id"]);
} catch (FormatException e) {
    /*
     * It's possible that the guid is not properly formatted and an
     * exception will be thrown, so handle that here.
     */
}
...