Finns det någon funktion i EPiServer som gör att jag manuellt kan ladda en sida?
Jag vill använda en asp:dropdownlist och dess OnSelectedIndexChanged för att navigera till en sida men vill helst inte använda Response.Redirect().
Have you considered Server.Transfer or do you mean a completely different way of navigation altogether?
Server.Transfer has its uses but whats wrong with Response.Redirect ?
Server.Transfer could be a solution but i have discovered some issues with EPiServer. The execution cannot be transfered to a EPiServer page cause it has to go directly to a physical file and not a "virtual" one as EPiServer pages would be; /Page____001.aspx
A Server.Transfer to /Page.aspx should work fine.
And I ask the same question as John Walsh, what's wrong with Redirect?
I created one simple page with two buttons, one Redirect and one Transfer.
The Redirect button peforms a Response.Redirect to the page "/templates/page.aspx?id=59" and works fine.
The Transfer button peforms a Server.Transfer to the page "/templates/page.aspx?id=59" and casts an exception "System.InvalidCastException: Specified cast is not valid".
If I change the url to "/templates/page____59.aspx" instead the results are similar.
Redirects works fine once again and Transfer fails yet again with the exception "Error executing child request for /templates/page____59.aspx".
Maybe I'm doing smething wrong?!
Oh I see what you mean - I thought it was complaining because there is no such page as page____58.aspx yet there is a page called page.aspx ...
either way - a good thread for future reference :)
I have tried Server.Transfer but received the error "EPiServer.Core.EPiServerException: The current template does not match the specified page type file".
I would like to avoid Response.Redirect() because it puts unnecessary load on the server by sending a new request. The other reason is that I loose the Viewstate.
So I thought EPiServer might have some convenient function letting me do a "redirect" without loosing the Viewstate.
Thanks for helping out.
Server.Transfer should work fine to do a server-side redirect (no client involved).
If you get the "template does not match the specified page type file" exception, it's because the page you are redirecting to cannot be accessed with the aspx file provided in the URL (by design, for security reasons).
You can override this behavior by compiling the aspx with the following override:
public override void ValidatePageTemplate()
{
}
I'm using a asp:dropdownlist to navigate to pages and thought it would be a good idea using server side forwarding instead of a redirect, mostly to leave the dropdownlist intact.
On the other hand this approach might not be useful after all as the viewstate is lost as soon as the user navigates to a page not using the dropdownlist. Dooh!
I will just have to save the dropdown settings in personalized data.