Asp Dot Net Notes for Web Masters RSS 2.0

# Saturday, November 28, 2009
In Sitefinity, when editing a page if you click properties you can enter extra page URLs.

Add a new URL something like "~/home.html" and click Save Changes.

Then Make all html pages run as though Asp.Net pages. Look here.

http://dotnetnotes.i-do-it.com/2009/11/28/MapHTMLPagesThrougthASPNETDllRunHtmlPagesWithAspnetisapidll.aspx


Then add this to the Global.Asax
 void Application_Error(object sender, EventArgs e) 
    {        
//Redirect missing Old html Pages to the default url of that page. Add Additional Urls to pages in sitefinity to redirect to those pages.
        Exception lastException = this.Server.GetLastError();
        if (lastException is HttpException)
        {
            HttpException httpException = (HttpException)lastException;
            if (httpException.GetHttpCode() == 404)
            {
                // get the name of the requested page - just the /thisPage.htm or /DIR/thisPage.asp etc
                string pageName = string.Concat("~", Request.Url.AbsolutePath.ToString());

                // create a new instance of CmsManager
                Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();

                // let's get the page by passing one of it's additional url's
                Telerik.Cms.IPage myPage = cmsManager.GetPageByAdditionalUrl(pageName);

                // we can cast myPage as ICmsPage and redirect to the Default URL
                if (myPage != null)
                {
                    //If there isa default page then redirect to it.                    
                    this.Server.ClearError();                    
                    Response.Redirect(((Telerik.Cms.ICmsPage)myPage).DefaultUrl.Url);
                }
            }
        }
    }

Saturday, November 28, 2009 12:01:48 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] - Trackback
Configuration
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
I do I.T. Ltd.
Sign In
Statistics
Total Posts: 27
This Year: 0
This Month: 0
This Week: 0
Comments: 22
All Content © 2012, I do I.T. Ltd.