Welcome to ASP.NET Guild

Be sure to come back often and tell others. If you have any tips, tricks, examples, please email them to me at chris.williams@techguilds.com and I will post them. Check out our ASP.NET QuickStart and C# QuckStart Libraries. Below is my latest articles.

Thursday, May 28, 2015

Redirect Url using IIS

Taken from https://support.microsoft.com/kb/324000

When you use Apache, you can redirect URLs by using the Redirect directive to point a folder or a location to a different folder on either the same Web site or a different Web site. You can also alias a folder to another location by using the Alias directive. If you use IIS, you can perform the same tasks by using the URL Redirection functionality.

To redirect a folder or file IIS:

  1. Log on to the Web server computer as an administrator.
  2. Click Start, point to Settings, and then click Control Panel.
  3. Double-click Administrative Tools, and then double click Internet Services Manager.
  4. Right-click the Web site or the folder, and then click Open.
  5. Right-click the folder display, point to New, and then click Folder.
  6. Return to Internet Services Manager.
  7. Right-click the folder that you just created, and then click Properties.
  8. Click the Directory tab, and then click A redirection to a URL.
  9. To redirect the folder to another URL, click the URL of the folder or the Web site that is described in step 4, and then type the complete URL to the new site in the Redirect to box.
  10. To redirect the folder to another folder within in this folder (for example, Projects to Sections/Departments/Projects), click A directory below this one, and then type the new folder in the Redirect to box.
  11. To mark the redirection type as a permanent redirection (and not a temporary redirection), click A permanent redirection for this resource
    If you use this setting, bookmarks and other details are automatically updated on some browsers.
  12. Click OK to save the changes.

Monday, May 18, 2015

ASP.NET Bootstrap Template Quickstart - Part 2: Using Email Address as UserName

When you first generate your application, the registration page insists on a UserName and Email Address from your clients, however it is more common to reduce the number of fields the user has to fill in as it increases registration.  The Email Address is much more valuable than the UserName as you can interact with it.

There are a couple changes you must make to use Email Address as the UserName:
  1. Change the UserName field to Email Address.
  2. In the control open tag you must add RequiresEmail=false
    If you forget to set this you will get the error message: 

    RegisterUser: CreateUserWizardStep.ContentTemplate does not contain an IEditableTextControl with ID Email for the e-mail, this is required if RequireEmail = true.

  3. Next you will want to add a validator to your username field to ensure it is in email format.  There are a few ways to do it.  You can use the RegEx Validator as a minimum or extend it to do a DNS lookup depending on your needs. Below is a sample I got from a StackOverflow article:

    <asp:RegularExpressionValidator ID="regexEmailValid" runat="server" ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="tbEmail" ErrorMessage="Invalid Email Format"></asp:RegularExpressionValidator>
If you have any tips, tricks or resources you would like to share with the guild email me at chris.williams@readwatchcreate.com

ASP.NET Bootstrap Template Quickstart - Part 1: Creating a new application

When you create your next project, choosing the WebForms application will do a lot more for you than previous versions. For example, you now get a solution built on Bootstrap, it uses friendly names for links eg. /About instead of /About.aspx. It provides you with two master pages: one for regular sites and one for mobile. To start using this template follow these steps:

  1. Open Visual Studio and choose to File -> New Project
  2. In the left panel Click on Visual C# -> Web -> Visual Studio 2012
  3. On the center panel choose ASP.NET Web Forms Application
  4. At the bottom choose where to put your project and give your project a name
Voila, you have yourself a great application to build on top of.  You can start applying your design and customization. 

In our followup articles we will cover some of the functional changes you may want to make to to this template to suit your needs.  

If you have any tips, tricks or resources you would like to share with the guild email me at chris.williams@readwatchcreate.com

Are you a .NET Developer or Contractor interested in working with Sitecore or Dynamics CRM?

Apply for our Mentorship Program. If accepted, we will mentor you on Sitecore and provide you with project to help you build your skills and make some money at the same time. If you are interested send your resume with details on why you want to work with Sitecore or Dynamics CRM to: Chris Williams - chris.williams@techguilds.com or Dennis Augustine - dennis.augustine@techguilds.com We look forward to working with you to achieve your goals.