Archive for the ‘VB.NET’ Category

  • ASP.NET Auto Logon

    Looking for how to auto logon a user into your web app? Try using this snip-it of code.

    FormsAuthentication.SetAuthCookie("usernamehere", True)

    I will work on a sample application to demonstrate how you can use this. Note that you can use this to login a user, that is not actualy registered with your application. You may want to run some kind of verification. Also, the best place to use this is in the “Login.aspx” file, given your using the .NET Login/Membership class.

    2009.08.20 / no responses / Category: VB.NET, Windows

  • Hide Menu Items Based on User Role…

    You can hid menu items in ASP.NET based on the current user roll. To do this, you have to configure the web.sitemap and web.config files. This example assumes you have roles setup for your site/application. So, lets get started.

    In your web.sitemap file, add the roll=”RoleName” to the end of every “siteMapNode” that you want to restrict. Please note that if you do not want to restrict a page, set roll=”*”, to enable the page for all users.

    Once you have setup your web.sitemap file, proceed to configure your web.config file. You will need to add the following code to your web.config file.

    <siteMap enabled="true">
    <add siteMapFile="Web.sitemap" name="AspNetXmlSiteMapProvider"
    type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>

    This will hide the menu item according to the user role. Congratulations, you now have a role driven menu system for your site/application.

    2009.08.15 / no responses / Category: VB.NET