Mono Support Lock entire site to unregistered users -- HELP!! 

Viewed 13512 time(s), 4 post(s), 5/9/2012 1:20:17 PM - by pevans
5/9/2012 1:20:17 PM
42 Reputation 3 Total posts

I want to lock my entire site, unless you are logged in. If you are not logged in it needs to redirect to the login page. I added the deny users line in the web.config file but then I get the following error:

HTTP Error 404.0 - Not FoundThe resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

<authorization>
   <allow verbs="enterSharedScope, modifyState" roles="Administrators,Users" />
      <deny users="?" /> <!-- Added this to lock entire site -->
</authorization>

Does anyone no what I did wrong or what I need to do to accomplish this? Thanks in advance

1
5/9/2012 2:04:00 PM
1871 Reputation 252 Total posts

I dont know if you can do it just by using the web config..

I think you would likely need to add your own custom master page and inside that write your deny logic..

Basically deny all pages but the login..

something like this I think..

using System;
using System.Collections.Generic;
using System.Web;
using MonoSoftware.MonoX.Utilities;

namespace TheScene.Web.MonoX.MasterPages
{
public class ThePittsburghSceneHeader
{

protected void Page_Load(object sender, EventArgs e)
{

//below code needs adjusted not sure how to do this with monox..
if ( this.Request.Url.ToString() != "login.aspx")

Guid userId = Guid.Empty;
userId = SecurityUtility.GetUserId();

if (userId != Guid.Empty)
{
//used logged in dont deny and redirectt.
}
else
{
//user not logged in redirect to login.aspx.
}

}

}


}

2
5/9/2012 3:17:09 PM
15993 Reputation 2214 Total posts

Hi,

yes you can accomplish this with only the web.config by setting the following (Not using the WebPart authorization tag but System.Web one):

<system.web>
...
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
...
</system.web>

Regards

3
5/9/2012 3:56:16 PM
42 Reputation 3 Total posts

Thank You so much that is exactly what I needed. I didn't realize that WebParts had authorization as well. I have never used them before.

4
This is a demo site for MonoX. Please visit Mono Software for more info.