Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Advay Pandya 11 posts 71 karma points
    Oct 10, 2014 @ 12:58
    Advay Pandya
    0

    Routing in Umbraco v6.0.5

    Hello All...

    I am working on Umbraco 6.0.5.

    My application contains both "Umbraco" and "ASP.net web forms".

    I am trying to configure routing in the Umbraco (with web forms) using "IRouteHandler".

    If I use my ASP.net web forms the routing is working as it should.

    But when I am trying to use "Umbraco" page the it throws exception message

    "The file '~/TestPage.aspx' does not exist."

    How many ways are there to fetch or get "Umbraco page" in GetHttpHandler method of IRouteHandler in ASP.net web forms ??

    Below is my code snippet of Global class:

    public class CustomGlobal : Umbraco.Web.UmbracoApplication
    {
        protected override void OnApplicationStarted(object sender, EventArgs e)
        {
            base.OnApplicationStarted(sender, e);
            RouteTable.Routes.Add(
                  "RouteName",
                  new Route("MyRoute/{Parameter}", new MyRouteHandler())
              );
        }

    Below is the CodeSnippet of MyRouteHandler class which is inherited by IRouteHandler 

     

    public class MyRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var result = BuildManager.CreateInstanceFromVirtualPath("~/TestPage.aspx", typeof(Page)) as Page;
            return result;
        }
    }


    Please advise

     

    Thanks

    Advay Pandya

  • Urvish 252 posts 776 karma points
    Oct 13, 2014 @ 06:55
    Urvish
    0

    Hi Advay,

    Try below code.

    public class MyRouteHandler : IRouteHandler { public IHttpHandler GetHttpHandler(RequestContext requestContext) { var result = BuildManager.CreateInstanceFromVirtualPath("~/TestPage.aspx") as Page; return result; } }

    Regards,

    Urvish

Please Sign in or register to post replies

Write your reply to:

Draft