Domanda

I am developing a SharePoint 2010 Project totaly in Visual Studio and C#.

I do not want to use SharePoint Designer and configuration via browser.

I need to set a LAYOUT page (application page) as home page on multiples sites.

Is it possible?

If not, which is the best aproach?

Important: I need to solve this situation only with c# no configuration

È stato utile?

Soluzione 3

Inspired by Arsalan Adam Khatri's answer I found a solution:

1) First create a page to handle the redirection:

LayoutPageRedirect.aspx

<html>
<head>
<META http-equiv="refresh" content="0;URL=./_layouts/folder/HomePageCustom.aspx">
</head>
</html>

2) Then create a module to deploy this file

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="ModuleLayoutPageRedirect">
    <File Path="ModuleLayoutPageRedirect\LayoutPageRedirect.aspx" Url="LayoutPageRedirect.aspx" />
  </Module>
</Elements>

3) Then change the welcome page

SPFolder rootFolder = currentWeb.RootFolder;
string home = "LayoutPageRedirect.aspx";
rootFolder.WelcomePage = home;
rootFolder.Update();

4) Finally Test

Enter http://server/site/web

Automatically goes to:

http://server/site/web/LayoutPageRedirect.aspx

And redirected to:

http://server/site/web/_layouts/folder/HomePageCustom.aspx

Altri suggerimenti

You cannot set Application pages as Welcome Page, only Site pages located either at the root web or from a Pages library.

But you can use a Redirect Page or redirection from your home page to layouts page.

Please refer to Possible to have the default landing page of my Sharepoint Site be an applicaiton page?

How to Set an Application Page as a default landing page in SharePoint 2013 web site

You can create a delegate control that would check if the current page is welcome page of the site. If Yes, then it would redirect to your application page using

C#

Response.Redirect(SPContext.Current.Web.Url + "/_layouts/YourApplicationPage.aspx");

JavaScript

window.location.href = _spPageContextInfo.webAbsoluteUrl + "/_layouts/YourApplicationPage.aspx";

Otherwise there is no direct way of setting an application page as welcome page.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top