How to define an MVC site in Sitecore (multisite) - asp.net-mvc

I'm currently using 7.1 update 2 running multiple sites using web forms. I'm starting a new site and want to use MVC but can't get it to work; however, I can get the default "website" to use MVC but not a custom site.
For example, let's say I have two sites, site1 and site2, site1 is web forms and works fine, how do I define "site2" which is MVC? Not sure what the value should be in the "physicalFolder" property. Or the site should be defined somewhere else.
Thanks
<site name="site1"
targetHostName="site1.com"
hostName="site1.com"
virtualFolder="/"
physicalFolder="/site1"
rootPath="/sitecore/content/site1"
startItem="/Home"
language="en"
database="master"
domain="extranet"
allowDebug="true"
enablePreview="true"
enableWebEdit="true"
enableDebugger="true"
enableWorkflow="true"
patch:before="site[#name='website']" />

The physicalFolder parameter will allow you to specify the physical path that Sitecore will look for any physical files it needs for the specified site. It is one of the options that can be used to organize the physical files for multisite instances.
You will see the following definition in the web.config comments:
physicalFolder: The physical location of files for the site.
If the site is based on physical files, this is the path to the folder holding the files.
For non-physical sites, this is the place where Sitecore looks for a default.aspx file (to start the pipelines).
You can find more information about the physicalFolder parameter here -> http://sdn.sitecore.net/Articles/Administration/Configuring%20Multiple%20Sites/Adding%20New%20Site/site%20Attribute%20Properties/physicalFolder.aspx
As for configuring your MVC site, there really isn't anything special you need to do in terms of your Site definition. You should just be able to replicate your Site1 definition and make the appropriate updates. Sitecore will utilize the correct rendering method based on the Layout and Sublayouts defined on your Pages.
<site name="site2"
targetHostName="site2.com"
hostName="site2.com"
virtualFolder="/"
physicalFolder="/site2"
rootPath="/sitecore/content/site2"
startItem="/Home"
language="en"
database="master"
domain="extranet"
allowDebug="true"
enablePreview="true"
enableWebEdit="true"
enableDebugger="true"
enableWorkflow="true"
patch:before="site[#name='website']" />

Related

IIS hosting ASP.NET MVC site gives http 404 for urls containing 'web.config'

Requesting a page from IIS (hosts ASP.NET MVC 3 site) with url containing web.config gives 404 error. Urls with app.config have no problem. Local Visual Studio development server has no issues with this type of urls.
1 - What are any other special words other than web.config, being handled this way by IIS?
In request filtering page/hidden segments tab this is the current state:
I guess these are not special words, because IIS handles words like bin, App_code etc without a problem.
Answer: I guess these are the words being handled by IIS this way. So these are the default words I think and this list is configurable (new items can be added to this list).
2 - Are there any quick fixes (like by web.config modification) to handle urls with these special words?
Btw, I am not trying to serve the web.config file. Url format is : www.mysite.com/es/web.config/1
This is part of the IIS configuration under the Request Filtering section:
You can add/remove filters.
However, I do believe this is a really bad idea to remove web.config from it.
http://www.iis.net/configreference/system.webserver/security/requestfiltering
Cause:
As you already shown a snapshot of IIS configuration. These are reserved folder & files in .Net application, so IIS want to preserve those for security.
URLs which contain these strings as returned as 404 response only if these comes in before ? AND exactly between 2 slashes /../ OR at last. Eg: www.example.com/bin/anything.ext OR www.example.com/folder/sub/web.config
IIS match these string anywhere coz, web.config can we at any directory level.
If anything is with those string are there THEN page will be served by IIS. Eg: www.example.com/bin-folder/anthing.ext OR www.example.com/sub/bin.html OR www.example.com/-web.confing/page.aspx are OK.
I recommend to use some other words with these strings OR use at end of URLs with extensions, so that it will not come between two slashes.
Eg: www.example.com/en-web.config/1 OR www.example.com/en/1/web.config.aspx
Even then I have one Tricky Solution:
If you really need these strings exactly without other words in URL THEN I recommend to use URL-ReWrite.. This may not be quick at whole but except 2nd step its quick and handy, coz second step depends on your application.
1- Add this rule in IIS at top level:
regexp match: (/web|^web)\.(config$|config/) //OR as your requirement
re-write to: handler.aspx?url={REQUEST_URI}
<rule name="web-config" stopProcessing="true">
<match url="(/web|^web)\.(config$|config/)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="handler.aspx?url={REQUEST_URI}" appendQueryString="false" />
</rule>
2- In handler.aspx (or in any other language page) check the url GET variable and respond accordingly.Request.QueryString("url")
Do it carefully coz here you are controlling security.
I suggest to include the actual page content to response in handler.aspx or handler.php only rather then redirecting etc.
Before including content verify URL first(by regular expression etc.), and include content hardcoded, do not take any part of URL in to variable and use that variable in response-inclusion-code.
3- After that at last from IIS manager, In a specific website go to request filtering->hidden segment tab and delete the desire string. Eg: web.config. This step can be done by web.config also:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200" />
<hiddenSegments>
<remove segment="web.config" />
</hiddenSegments>
</requestFiltering>
</security>
Now, IIS will serve the page and your handler page will show the output with exact same URL in user browser.

Url Rewriting in Umbraco 5 Jupiter

i want to do simple URL re-writing in Umbraco 5 like we used to do in previous versions i-e changing the UrlRewriting.config file, or we used to do it in Asp .Net
<rewriter>
<rewrite url="~/en/faq.aspx" to="~/faq.aspx" />
</rewrite>
I know we can create new area in the application and then add new routes in areaRegisteration.cs. but then the problem of mapping these controllers to the default Views arises, as the views are in: Views > Umbraco Directory of the application.
For example,
I create a new Area Named "En" and add Route in EngAreaRegisteration.cs, i-e
context.MapRoute("en_property","en/{city}/{controller}/{action}",new { } );
then how i can map the Actions to any Umbraco Page, i dont think the Redirect is a solution as redirect will change the Url,
my URL will be like this, en/paris/property/book
i am using Umbraco 5.0.1 Web deploy.
Thanks in Advance
Sher

Umbraco Alternative Links doesn't work

Hello I created some page in Umbraco 4.7 CMS,
configure some alternative links to page(section) it looks like.
If I look at
Link to document
/folder/folder2/page1.aspx - workig
Alternative Links
http://site.com/folder/folder2/page1.aspx - workig
http://site.com/en/folder/folder2/page1.aspx - not working
http://site.com/old-folder/folder2/page1.aspx - not working
but in browser just /folder/folder2/page1.aspx show a valid page other links redirect users to 404 page that configured in umbraco config file.
Have you considered using the UrlRewriting module to get this working. You could add a new rule similar to the following:
<add name="page1rewrite"
virtualUrl="^~/en/folder/folder2/page1.aspx"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/folder/folder2/page2.aspx"
ignoreCase="true" />
This could be further improved depending on your exact requirements but you could it you wanted rewrite all urls ~/en/folder/folder2/ to the new location.
An alternative option would be to use the umbracoUrlAlias document type property.

MOSS how to use feature to propagate pages in root site to child sites

I have a publishing site, say http://dev. I've created a page called About.aspx, so the url would be http://dev/Pages/About.aspx. I'd like to use Feature so that the About.aspx page is available when users access it from the child sites, for example: [http]://dev/2010-01/Pages/About.aspx, [http]://dev/2010-02/Pages/About.aspx, and so on, without having to copy the About.aspx to each site.
Have these sites already been created? If not you could create your own site definition and add it using a module
<Module Name="AboutPage" Url="Pages" RootWebOnly="FALSE">
<File Url="About.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
</Module>

Localization in ASP.NET MVC

Visual Studio 2008
I want to bring some localisation into my ASP.NET MVC site.
Someone suggested creating a resource file "Strings.resx" as a publically strongly typed resource, which works nicely and allows me to write
<title><%= Strings.MyView_Title %></title>
I then proceeded to add a file "Strings.da.resx". This file is created right next to the first one, and defaults to "Access Modifier : No Compilation", whereas the first (the one without language modifier) defaulted to "Interal".
I can see in the bin directory that a directory has been created ("da") with a resource.dll, however, I cannot see any of the translated texts on my site.
I have checked with the browser that the only preferred langauge is Danish (da-DK), but I only see the english texts.
Questions:
1) Do I need to enable something in web.config ?
2) Am i creating the right files, with the correct types (i.e. should #2 be "No compilation") ?
In your views, do you have a page directive?
If so, do you have UICulture="Auto" and Culture="Auto"?
For example...
<%# Page Language="C#" Inherits="..."
culture="auto" uiculture="auto" %>
This will ensure that the Accept-Language header, passed by the browser in the request, gets used to set the Thread cultures. It's the UICulture that influences which resource file to pick.
For more on ASP.NET i18n this book is very good...
http://www.amazon.co.uk/NET-Internationalization-Developers-Guide-Building/dp/0321341384/ref=sr_1_1?ie=UTF8&s=books&qid=1241010151&sr=8-1
It doesn't cover MVC, but covers ASP.NET and, as such, many things continue to be relevant.
First you have to create action filter that will switch culture of request thread.
OR
Set your globalization element to UICulture="Auto" and Culture="Auto"
Check this screencast, it is in Russian but code samples are understandable.

Resources