what determine the start page?

Jan 18, 2011 at 3:59 PM
Edited Jan 18, 2011 at 4:02 PM

I know this question is somewhat stupid but not as easy to explain as it looks. But I'm really curious about it.

When I press F5 in Visual Studio, the project runs and the start page is: http://localhost:30320/OrchardLocal/

But I am confused about what determine the start page, where is the source code of start page? I check the property of the startup project Orchard.Web and try to step into in debug but failed.

I am a .Net developer who is used to WebForm but know a little Asp.net MVC and Razor.

Thanks very much in advance.

 

PS: I'd appreciate if you tell me where the code create the tables in database when the application is initiated! :-)

Coordinator
Jan 18, 2011 at 4:03 PM

There is no start page in the way it is defined in Webforms. In ASP.NET MVC a request to "/" is sent, then all route definitions are processed to determine which controller will answer. In Orchard, in every module you will fin a Routes.cs file defining those routes. You will find one in Orchard.Core's HomeController which answers to it. The goal of this module is to display the Content Item which has been marked as the home page. That how other modules can suggest the user to put specific contents as the homepage, like in Blogs for instance.

Sebastien

Jan 18, 2011 at 4:26 PM

Oh, find it. Marvellous! Thanks very much!

Mar 25, 2011 at 1:14 PM

Is there a way to add a landing landing.html page. 

which would look like

You shall not pass 

unless you tick this box

<input name="i_obey" type="checkbox" />

<input onclick="window.open(" type="button" value="and click this button" />

and then you click you would go to 

onclick="window.open('orchard_home');"

or get alert that you need to tick box.

making a content item would not work because you can see all the menu items. so you would jest go where you want.

 

Mar 25, 2011 at 2:09 PM

heres how to add html pages to your site

http://orchard.codeplex.com/discussions/241935

how to set html page to be a start page in orchard is still a mystery

Mar 25, 2011 at 3:15 PM

You can put a Layout-HomePage.cshtml in your theme's ~/Views folder. Although I think this can only work out-of-the-box in 1.1; if you're on 1.0 you can use either method described in the following post to switch layouts: http://orchard.codeplex.com/discussions/250643 . This way you can override the entire layout of the home page.

Mar 25, 2011 at 5:11 PM

works straight forwardly 

Steps:

1) make folder in Orchard.web lets say /Statics

2) make web.config inside of folder copy this 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>
  <system.web>
    <httpHandlers>
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <add path="*" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers accessPolicy="Script,Read">
      <!--
      iis7 - for any request to a file exists on disk, return it via native http module.
      accessPolicy 'Script' is to allow for a managed 404 page.
      -->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>

go to Orchard.Web project then Top menu -> Orchard.Web properties -> Web -> and in specific page field  'Static/Startup.html' 

that it :)

Oh and make Startup.html in folder :)

 

Mar 25, 2011 at 6:21 PM
mataswork wrote:go to Orchard.Web project then Top menu -> Orchard.Web properties -> Web -> and in specific page field  'Static/Startup.html' 

that it :)


That will make Visual Studio automatically start you on that page whenever you Run or Debug. But it won't make any difference to the default root page when your site is live on a web server!

To override the actual home page you need to work within Orchard's constraints - I think you will still need to take the steps I described :)  (Unless you have access to IIS on your webserver and can implement rewriting at a low level...)

Mar 25, 2011 at 6:30 PM
Edited Mar 25, 2011 at 6:31 PM
and then you click you would go to 

onclick="window.open('orchard_home');"

or get alert that you need to tick box.

making a content item would not work because you can see all the menu items. so you would jest go where you want.

P.S. I would strongly recommend against what you're trying to do.

1) Search engines won't be able to crawl your website if the only link to your website's content is thru a Javascript window.open - you will destroy your rankings.

2) Not all users or web clients have Javascript enabled. You are preventing people from using your site.

3) People don't always arrive at your site through the landing page as you would like. It's perfectly possible for anybody to link to a Url within your website, and your landing page would be skipped.

4) Requiring people to perform an extra two mouse clicks before they can even see anything will put visitors off even bothering. The internet is about getting information immediately, not keeping it hidden away behind layers of unneccessary user interface.

5) Splash pages are bad bad bad!

Of course there are use cases and applications where such a system might be desirable. But they are few and far between :)

Coordinator
Mar 25, 2011 at 6:36 PM

+1 to that. It is extremely bad practice, especially for a web site. You are only going to drive people away from your web site.

Note: putting the site behind an authentication wall on the other hand is ok if the site must be restricted to known users, but that is not what we're talking about here as far as I can tell.

Mar 28, 2011 at 8:42 AM

This feature was requested by client, the medical association, the can get legal issues if they will not add this, but if you have any ideas please share. 

It has to be: 

----------------------------------------------

Yes I am a doctor <input type="checkbox" />

<input type="button" value="I realy am" />

----------------------------------------------

we trust people so no authorization, jest this. 

We did suggested popup and alert but they want a page. 

If you can suggest something like this, but not killing Search Engine please share. Thank you. 

Mar 28, 2011 at 8:44 AM
randompete wrote:

4) Requiring people to perform an extra two mouse clicks before they can even see anything will put visitors off even bothering. The internet is about getting information immediately, not keeping it hidden away behind layers of unneccessary user interface.

5) Splash pages are bad bad bad!

 

I too have read "Don't make me think"  ;)

Mar 28, 2011 at 10:08 AM

It's one of those "having your cake and eating it" type scenarios.

You can force any page to redirect to the front page if the user hasn't got a cookie to confirm they clicked the button.

A search engine will never have that cookie; it doesn't know to tick the box and click the button.

So search engines will only ever see a redirect to your front page.

*Although* you could use the Vandelay theme picker to return a different theme for search engine user agent strings. But this would then mean that Google caches your site content and suddenly anyone can view it the content again!

So basically anything that thoroughly blocks people will also block search engines.

As long as your clients are aware of this side effect, there's nothing stopping you doing it - but how you implement some kind of site-wide cookie check and redirect I'm not immediately sure.

Mar 28, 2011 at 11:43 AM

I wouldn't. Clients don't care if someone will get into site indirectly (bypassing that page). It's a feature that has to be there. Not make sense or work properly 

Mar 28, 2011 at 2:01 PM

Ok... well, "customer knows best" ;)

Coordinator
Mar 29, 2011 at 1:54 AM

I suppose you could assign a Doctor role to the user when he clicks that button and checks that checkbox. Would he be authenticated at this point?

Mar 29, 2011 at 8:26 AM
Edited Mar 29, 2011 at 10:23 AM

The page is open - without authentication, I could read ip but that would be illegal I think, now I put cookie.

heres whole mechanism

home page:

<script type="text/javascript">// <![CDATA[
checkCookie('aaa');
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}
function checkCookie(ck)
{
var cook=getCookie(ck);
//alert(cook);
  if (cook!=null && cook!="")
  {
  //alert('cookie ok');
  }
else 
  {
  window.open('/OrchardLocal/Static/verification.html','_self');
  }
}
// ]]></script>
 then verification.html:
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script>
<p>HOME PAGE</p>

 

<div>I confirm that I am a profesional*      <input id="confirm" type="checkbox" />
 <input onclick="if(!$('#confirm').attr('checked')){ alert('You may not pass\nYou are not profesional'); return false;} else {
 setCookie('aaa','true',356);
 window.open('../','_self');}" type="submit" value="I confirm that I am a profesional" /></div>
<p>*<span style="font-size: xx-small;">Ticking the box makes you professional</span></p>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript">
</script>
<script type="text/javascript">
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
c_value= c_value+"; path=/";
document.cookie=c_name + "=" + c_value;
}
</script>

 

to be able to add html pages you have to create folder in Orchard.Web

 

and put Web.config into it

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>
  <system.web>
    <httpHandlers>
      <!-- iis6 - for any request in this location, return via managed static file handler -->
      <add path="*" verb="*" type="System.Web.StaticFileHandler" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers accessPolicy="Script,Read">
      <!--
      iis7 - for any request to a file exists on disk, return it via native http module.
      accessPolicy 'Script' is to allow for a managed 404 page.
      -->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>

 


Coordinator
Mar 29, 2011 at 8:30 AM

If you do that on the client-side, it's just too easy to work around: come into the site with JavaScript disabled.

Mar 29, 2011 at 10:15 AM
Edited Mar 29, 2011 at 10:22 AM

Ofc, but we don't care :) 

If we would, there would be a login page, not a box to tick. 

Or at least you should input sort of code which would be given befrehand.

Or email check. Or any sort of proof that you are allowed to go inside. 

But client does not care if you bypass this page, the script is only on home page so if you would go to any other page it would not check for cookie and let you in.

This page is for legal issues.  

Coordinator
Mar 29, 2011 at 10:34 PM

OK then, just wanted to be sure that whoever visits this thread and tries to use this code is aware of the security implications ;)