得到错误而重定向的反应是不是在这种情况下,可用' [英] Getting error while redirecting 'Response is not available in this context'

查看:98
本文介绍了得到错误而重定向的反应是不是在这种情况下,可用'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下code到用户重定向到一个页面。

I am using following code to redirect user to a page.

Session["USERDATA"] = user;
if (roleName.Equals("Zerker", StringComparison.CurrentCulture))
   Response.Redirect("~/Account/Dashboard.aspx");

但是这导致了错误。

but this causing the error.

响应不可用在这方面。

我应该怎么办?

推荐答案

我认为你正在使用响应对象在自己的类。这个对象将不可用在那里。

I think you are using response object in your own class. This object will not be available there.

尝试使用

HttpContext.Current.Response.Redirect("~/Account/Dashboard.aspx");

这篇关于得到错误而重定向的反应是不是在这种情况下,可用'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆