TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sri Ram
1.6k
173
99.8k
Using Response.Redirect in MVC action
Jun 21 2017 10:00 AM
I have an action method in a controller class as shown below and based on a if condition, system should redirect to MVC page. But, Response.Redirect is not working as expected and throws an exception "Cannot redirect after HTTP headers have been set".
[HttpGet]
public
ActionResult GoToPage(
string
pageName)
{
var path = GetPagePath(pageName.Trim());
if
(!
string
.IsNullOrWhiteSpace(path))
{
// framing the fully qualified path
path =
string
.Format(
"{0}/{1}"
, ConfigurationFactory.GetConfigurationProvider().GetAppBaseUrl(), path);
if
(!path.ToLower().Contains(
".aspx"
))
{
Response.Redirect(path)); error line
}
return
Redirect(path);
}
else
{
return
RedirectToAction(
"AccessDenied"
,
"Error"
,
new
{ area =
""
});
}
}
Can someone help on this?
Reply
Answers (
1
)
How can i show data in a table in asp.net
Dropdownlist in mvc5