tags:

views:

37

answers:

3

In MVC pattern where does the response.redirect will come.Either in view and controller.

A: 

It will definitely come in controller.

Sarfraz
Does it return the page where it has to redirect in the view or will it redirect in the controller itself.If its in Controller itself, it has to use Web.UI.Page class.Tomorrow if we are going to convert the application to Windows application then we need to change the controller too.Am I right or Wrong?
Ramesh
@Ramesh: You should redirect it to a different controller path (sometimes redirection is done to same controller depending on requirement). The redirected controller will show the associated view.
Sarfraz
+1  A: 

I'd also say in the controller. the view is only responsible for displaying the data and maybe doing a little data fetching. Although I'm restricting my views to just displaying and formatting.

So the controller has all the information when to redirect. So the result of a controller action is either a redirect or a view rendering. (Where presenting a download is considered as view rendering)

Patrick Cornelissen
Okay, tomorrow If need to change the project as Windows application, then I need to change Response.Redirect in all the places where ever I used it right?
Ramesh
I am not sure what you are trying to do. A little mor einformation about the enviroment (language, frameworks etc.) would be good
Patrick Cornelissen
+1  A: 

Must be in Controller. Controller's name suggested that every control statement must come in the Controller. View is responsible for the Design code only.

KuldipMCA
Okay, tomorrow If need to change the project as Windows application, then I need to change Response.Redirect in all the places where ever I used it right?
Ramesh
i have already work on the web and window application in MVC.For Windows application you have to create one property in VIEW class that will return the View object and use that property in the Controller class and you can replace that thing in the Windows application for Response.Redirect with SHOWDIALOG
KuldipMCA