sreeraj.sa
sreeraj.sa

Reputation: 55

Redirecting Ascx page

Is it possible to redirect an ascx page using

Response.Redirect();

My code is

HttpContext.Current.Response.Redirect("~/postauthenticated/employeereprintw2requestconfirmtest.ascx");

Do you have any idea?

Upvotes: 2

Views: 3113

Answers (3)

Suhaib Janjua
Suhaib Janjua

Reputation: 3572

No, It is not possible to redirect to a user control by using Response.Redirect(); because a user control (.ascx) is just a partial page not a complete page to which you can redirect your controls. A user control cannot exist alone without a WebForm. So a user control (.ascx) always needed to register itself in a WebForm (.aspx) before accessing it. One WebForm (.aspx page) can have multiple user controls (.ascx) as they are partial pages. So multiple user controls can be registered on One WebForm in ASP.NET.

Upvotes: 2

siddhesh
siddhesh

Reputation: 387

No its not possible. We can not redirect to .ascx. In short .ascx is not page to redirect. Its a user control. If we need to use it,we have to put it on any page and then only it can be visible in the browser. We never use .ascx as stand alone.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1039498

No, that's not possible. An ASCX control cannot live alone. It should always be hosted in a WebForm (ASPX). And you can only redirect to WebForms or generic handlers. Actually only to generic handlers which are the basic entry points for web requests. The WebForms is just a custom generic handler.

Upvotes: 3

Related Questions