• Republishing Pages in Sitefinity 4.X

    by Venkata Koppaka | Jun 20, 2011

    If you would like to Republish pages in Sitefinity 4.X for any reason this post will help you write a custom page to do this task.

    Up until 4.1 this Republish page is a very important page to have as when you make changes to the template, the content pages did not get the latest changes from the template. You had to open up each and every content page and then hit Publish on that page. This is a cumbersome task especially if you have a lot of content pages.

    To ease up this procedure here is a quick asp.net page to Republish all pages(and clear the cache) -

    Create a page called RepublishPages.aspx on the root of the Sitefinity website. In the code behind of that page copy & paste the following code -

     

    1 using System; 
    2 using System.Linq; 
    3 using Telerik.Sitefinity; 
    4 using Telerik.Sitefinity.GenericContent.Model; 
    5 using Telerik.Sitefinity.Modules.Pages; 
    6 using Telerik.Sitefinity.Pages.Model; 
    7  
    8 namespace SitefinityWebApp 
    9
    10     public partial class RePublishPages : System.Web.UI.Page 
    11     { 
    12         protected void Page_Load(object sender, EventArgs e) 
    13         { 
    14             var pageNodes = App.WorkWith() 
    15                                          .Pages() 
    16                                          .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend) 
    17                                          .Get() 
    18                                          .Where(pN => pN.Page.Status == ContentLifecycleStatus.Live) 
    19                                          .ToList(); 
    20             foreach (PageNode p in pageNodes) 
    21             { 
    22                 var myId = p.Page.Id; 
    23                 var manager = PageManager.GetManager(); 
    24                 var myDraft = manager.EditPage(myId, true);                 
    25                 manager.PublishPageDraft(myDraft, true); 
    26                 manager.SaveChanges(); 
    27             } 
    28         } 
    29     } 
    30

    And whenever you want to Republish pages just browse to this page and all the pages would be published with the latest changes.

     NOTE: Majority of the code is from this discussion - Not answered Adding content to template does not show on pages but changed a little according to my comment here .

    If you would like to download the Republish Page on the whole (aspx and codebehind)  Click Here

    Hope this helps

    Cheers

    Venkata


    Go comment!
  • Working with ambigious controller names in MVC3

    by Venkata Koppaka | Apr 30, 2011

    If you are working with ASP.NET MVC2 or above you might want to have same controller name across multiple areas. For example you might have an Home Controller on your root of your website and also a Home Controller on the Admin Area of your website. Looks like a a reasonable thing to have

     

    But if you run your application you will have an error saying "Multiple Types were found that match the controller..." or like the screenshot below

     

    To overcome this error you need register a route specific to the area with the namespace. Use the code snippet below-

    public static void RegisterRoutes(RouteCollection routes) 
            { 
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
     
                //General Route 
                routes.MapRoute( 
                    "Default", // Route name 
                    "{controller}/{action}/{id}", // URL with parameters 
                    new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults 
                    new string[] { "AmbiguousControllers.Controllers" } 
                ); 
     
                //Route for Admin Area 
                routes.MapRoute( 
                    "Admin Default", // Route name 
                    "{controller}/{action}/{id}", // URL with parameters 
                    new { area = "Admin", controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults 
                    new string[] { "AmbiguousControllers.Areas.Admin.Controllers" } 
                ); 
     
            } 

    And now you can have multiple controllers with the same name.

     Hope this helps,

    Cheers

    Venkata

    Go comment!
  • Making your website IE9 friendly

    by Venkata Koppaka | Mar 21, 2011

    IE9 was released recently. It is brand new browser from Microsoft, which uses their new "Chakra" Javascript engine which makes it the fastest browser till date (even beating Chrome 10).

    IE9 has an interesting feature called "Site Pinning". This blog post talks about how to change your website to make use of that and give the users of your website a "app" feel on Windows 7.

    To begin with let us first add a shortcurt icon

    Add this line in the HEAD section of your page.

     

        <link rel="shortcut icon" type=image/x-icon href="/images/shortcut.png" /> 
     

    and when you drag the tab in IE on to your Windows 7 taskbar, your shortcut icon shows up in task bar and the the you get a nice color scheme which is similar to your website when you open your website.

     

    IE9 also lets you add "Jump list tasks", which can be done by the following snippet -

    <meta name="msapplication-task" content="name=Follow on Twitter;action-uri=http://twitter.com/subbaraokv;icon-uri=/images/twitter_ico.ico" /> 
        <meta name="msapplication-task" content="name=Subscribe to Feed;action-uri=http://www.bluegenegeek.com/blogs.rss.ashx;icon-uri=/images/feedicon.ico" /> 
        <meta name="msapplication-task" content="name=About Me;action-uri=http://www.bluegenegeek.com/About.aspx;icon-uri=/images/AboutMe.ico" /> 

    The basic idea behind the above above snippet is you can add "tasks" with your own text and urls and have a nice little icon to go along with it.

    Once this is done this is how it would look like -

     

    Hope this helps

    Cheers

    Venkata

    Go comment!
  • Json Request Behaviour in MVC2

    by Venkata Koppaka | Nov 23, 2010

    If you are working with a MVC2 project, or happen to upgrade a MVC1 Project to a MVC2 Project you might run to some issues while getting Json data using AJAX calls.

    Specifically MVC 2 will give you an error which says

    This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

    To get past this error all you need to do is Allow Json data to be gettable in your Controller Action method.

    You can obtain this by the following line –

    1 return Json(data, JsonRequestBehavior.AllowGet); 

    The above line will solve your problem.

    Hope this helped,

    Cheers,

    Venkata


    Go comment!
  • Changing you Application Title in Windows Phone 7

    by Venkata Koppaka | Nov 21, 2010

    This is another quick post in which I will show you how to change Application Title in Windows Phone 7 Application List.

    Here is how the "Save the world Ninja!" app title is looking right now (If you haven't had a chance to read the post I did on how to create the Save the world Ninja! app I would suggest that you do here.) 

    Now I want to change this title to something more meaningful.

    To change the title of your app in Windows Phone 7 App list, open up WMAppManifest.xml file in the properties folder of your Windows Phone 7 Project.

    In the WMAppManfiest.xml file you will find a node called "App" and change change that line to be something like this

    1 <App xmlns="" ProductID="{97a383c7-abb9-40ec-839d-0ac3aa168ccb}" Title="Save the World, Ninja!" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal"  Author="Venkata Koppaka" Description="Save your world Ninja!" Publisher="Venkata Koppaka"> 

    Note the title in the above XML has been changed to "Save the World, Ninja!". I actually changed the Application icon the Windows Phone 7 App shows, here is how you would put your own  icon.

    1 <IconPath IsRelative="true" IsResource="false">ninja.png</IconPath> 

    And now if I run my App this is how it would look like -

    If you wish to checkout the updated code, its checked in to GitHub here -https://github.com/subbaraokv/Hello-World---Windows-Phone-7

    Hope this helped,

    Cheers,

    Venkata

    Go comment!