IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

Migrating ASP.NET 1.1 to Windows Server 2012

With Microsoft cutting the support for Windows 2003 by July 2015, many legacy web applications built with .NET Framework 1.1 have to be migrated to a newer Windows Server 2012 R2. The dilemma is that .NET Framework 1.1 is no longer supported (it’s not even possible to manually install the .NET Framework 1.1 on these platforms) on Windows Server 2012 or Windows Server 2012 R2.

The proposed solution by Microsoft is to install the .NET Framework 3.5 SP1 which includes the .NET Framework 2.0. Most ASP.NET 1.1 applications should run under .NET Framework 2.0 without re-compiling or re-writing of codes so long as they don’t have any runtime breaking changes, whether it’s API or behavior.

Further Reading

Breaking Changes in .NET Framework 2.0
List of Breaking Changes
Running .NET Framework 1.1 Apps on Windows 8, Windows 8.1 or Windows 10
Microsoft .NET Framework 1.1 and 2.0 Compatibility
Runtime Breaking Changes

February 8, 2014 Filed Under: .NET Tagged With: ASP.NET, Microsoft, Windows Server

How to Setup SQL Express LocalDB in ASP.NET

Microsoft SQL Server Express LocalDB should be used in place of the SQL Server Express user instance feature which is deprecated. It is more suitable for developers as it runs on-demand (instead as a service) with your Windows credential and without the need the need of complex configurations.

In Visual Studio 2013, if you want to have it setup a default database using a SQL Server LocalDb in your Web.Config, make sure you choose Individual User Account as your authentication mode.

New ASP.NET Project - Select a template

Then you can modify the parameters and commit Update-Database later.

<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, 
         visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" 
         connectionString="Data Source=(LocalDb)v11.0;AttachDbFilename=|DataDirectory|aspnet-WebApplication1-20131218041336.mdf;Initial Catalog=aspnet-WebApplication1-20131218041336;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    ...

Further Reading

SQL Server 2012 Express LocalDB
Introducing LocalDB, an improved SQL Express

December 18, 2013 Filed Under: .NET, How To Tagged With: ASP.NET, MVC

How to Override Telerik RadGrid CSS

If you use Telerik’s RadGrid but don’t want to use the default styling template, there’s a quick way to apply your own CSS style to it. This may not be as sophisticated as using the skinning feature, but it surely does the trick.

The first thing we need to do is to write the custom css style, then assign it to CssClass attribute within the RadGrid markup. We also need to add Skin attribute with an empty value.

So we’re going to create the custom CSS first, then add the two attributes on the RadGrid Control markup as shown in the example below:

Create Custom CSS

RadGrid is rendered as an HTML table on the ASP.NET page, so make sure you style it as a table element. In this example, we’ll name our CssClass element rgview.

<style type="text/css">
    .rgview table
    {
        border-collapse: collapse;
        background: #ebf1de;
    }
    .rgview th, .rgview td
    {   
        padding: 4px 8px;
    }
    .rgview th
    {            
        background-color: #8064a2;
        color: #fff;
        border: 1px solid #ccc;
    }
    .rgview th a
    {
        color: #fff;
        text-decoration: none;
    }
    .rgview tr:hover
    {   
        background: #d8e4bc;
    }
    .rgview td
    {
        border: 1px solid #ccc;            
    }
</style>

Add Markup Attributes

Add Skin=”” and assign the css to CssClass attribute. See the highlighted section.

<telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0"
    DataSourceID="dsITNota"
    GridLines="None"
    AllowPaging="true" 
    AutoGenerateColumns="false" 
    ShowStatusBar="true"
    OnItemUpdated="RadGrid1_ItemUpdated" 
    OnItemCommand="RadGrid1_ItemCommand" 
    OnPreRender="RadGrid1_PreRender"
    CssClass="rgview" Skin="">
    
   ...

</telerik:RadGrid>

That’s all there is to it. Here are the screenshots to show the difference between the default and custom style.

Default

Telerik RadGrid Default Style

Custom

Telerik RadGrid Custom Style

July 24, 2013 Filed Under: .NET Tagged With: ASP.NET

How to Use IIS Express in Visual Studio

Download Microsoft IIS Express 7.5 MSI file.

Double-click on the iisexpress_1_11_x86_en-US.msi file and you’ll see the IIS 7.5 Express Setup Wizard dialog as shown below pops up.
IIS Express Setup Wizard

Keep clicking on Next until the last page. Click on the Finish button.
Finish IIS Express Setup Wizard

You can also install IIS Express from Microsoft Web Platform Installer.

Setup Microsoft Visual Studio 2010 to use IIS Express

Open the solution using Visual Studio 2010.

From the Menu, select Project, [Solution name] Properties.
Visual Studio, Solution Properties

Select the Web tab and make sure the radio button Use Local IIS Web server is checked. If the application is run for the first time, Visual Studio will ask if Virtual Directory can be created. Just click OK, Save Selected Items (CTRL+S) and close the tab.
Visual Studio Web Properties

If your web application uses Windows Authentication (i.e. Intranet Application), you also need to modify the applicationhost.config file in C:\Users\[Username]\Documents\IISExpress\config directory (You need to replace [Username] with your real username in your computer).

Edit \My Documents\IISExpress\config\applicationhost.config

<system.webServer>
...
  <security>
  ...
    <authentication>
      <anonymousAuthentication enabled="false" userName="" />
      <windowsAuthentication enabled="true">
    </authentication>
  ...
  </security>
...
</system.webServer>

That’s it as far as the IIS setup goes.

Running Your Web Application with IIS Express

From Visual Studio 2010

Once setup, you can run the web application directly from Visual Studio 2010 by running with Start Debugging (F5) or Start without Debugging (CTRL+F5).

From the Command Line

To run your web application outside Visual Studio, just run the command line. Type ‘cmd’ from the Search programs and files box after you click the Start button.

Windows 7 32-bit

Type cd Program FilesIIS Express

Windows 7 64-bit

Type cd Program Files (x86)IIS Express

For help just type iisexpress /?

To run your web application right away, type iisexpress /site:WebAppName and replace WebAppName with the Assembly name of your web application (in this case Mvc4).
Web Application Assembly Name

IIS Express Command Line

You can view your web application by typing the URL in your browser as indicated in the command line dialog box (from this example, it’s http://localhost:50814).

Further Reading:
IIS Express Overview
Benefits of using IIS Express
Running IIS Express from the Command Line

Install Internet Information Services (IIS) Express 7.5

May 15, 2012 Filed Under: .NET Tagged With: ASP.NET

How to Setup User Access and Roles in Production SQL Server

Setting up ASP.NET membership and roles in development is very easy to do since out of the box, it’s already configured to use the built-in SQL Server Express provider. To set it up, you just need to launch ASP.NET Web Site Administration Tool by clicking on ASP.NET Configuration icon in the Solution Explorer or choose the ASP.NET Configuration option from the Project menu.

ASP.NET Configuration icon

Once you complete the configuration, a SQL Server Express database named Aspnetdb.mdf is created locally and ready to use. While this is very practical and suitable for development, it’s definitely not the best practice for production. It is highly recommended that a full-blown SQL Server is used in the production environment instead.

For a more detailed instructions on how to setup the user and roles in localhost, refer to the step-by-step guide from Scott Guthrie, Walkthrough: Managing Web Site Users with Roles included in the Further Reading on the bottom of this post.

Setting Up Application Services in Production

Configuring ASP.NET 4.0 Application Services to Use SQL Server 2008 in production database can also be done quite painlessly. The first step is to find ASP.NET SQL Server Setup Wizard on your local ASP.NET installation. Open a command-line window by opening the Start Menu and typing ‘cmd’ (without quotes) in the search box.

Change to directory C:\Windows\Microsoft.NET\Framework\v4.0.30319
or C:\Windows\Microsoft.NET\Framework\v2.0.50727 if you’re still using .NET Framework 2.0 or 3.5.

Look for a file called aspnet_regsql.exe and run it. By default when run without any parameters, it actually uses -W (Wizard mode) argument. You can use -? argument to see the list of all available parameters.

aspnet_regsql.exe from Command Line Window

ASP.NET SQL Server Setup Wizard Welcome Screen

ASP.NET SQL Server Setup Wizard Setup Option

ASP.NET SQL Server Setup Wizard Select the Server and Database

Substitute SQLSERVERPROD with your SQL Server Production server name and YOUR_DB_NAME with the database name where you want your application services configured. Then click Next >.

ASP.NET SQL Server Setup Wizard Confirm Your Settings

Click Next > and the wizard will run for a while until you see this screen:

ASP.NET SQL Server Setup Wizard The database has been created or modified.

Click Finish and a new and empty Membership and Roles infrastructure is ready to use in your production database.

Setup Web.Config Parameters

The second step is to update the ConnectionStrings in your Web.config file. If you use Visual Studio 2010 and .NET Framework 4.0, it’s even better as you only need to add the settings for your PROD in Web.Release.config file and never need to worry about switching the parameters between the DEV and PROD afterwards.

Web.config

<connectionStrings>
  <add name="AspNetSqlRoleProvider" 
    connectionString="Server=.SQLEXPRESS;
    Database=YOUR_DB_NAME_DEV;
    Trusted_Connection=yes" 
    providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
  <roleManager enabled="true" 
    defaultProvider="LocalSqlServer">
    <providers>
      <clear />
      <add name="AspNetSqlRoleProvider"
        applicationName="/" 
        connectionStringName="LocalSqlServer" 
        type="System.Web.Security.SqlRoleProvider" />
    </providers>
  </roleManager>
</system.web>

Web.Release.config

<connectionStrings>
  <add name="AspNetSqlRoleProvider" 
    connectionString="Data Source=SQLSERVERPROD;
    Persist Security Info=True;
    Initial Catalog=YOUR_DB_NAME;
    User ID=myuserid;Password=dbpassword123"
    providerName="System.Data.SqlClient"
    xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</connectionStrings>

The new database is going to be empty and this is what I like best as I don’t want to copy over various test user ids to production.

Further Reading:
Walkthrough: Managing Web Site Users with Roles
Configuring ASP.NET 2.0 Application Services to Use SQL Server 2000 or SQL Server 2005
Users and Roles On The Production Website (C#)

January 18, 2012 Filed Under: .NET, How To Tagged With: ASP.NET, MVC

« Previous Page
Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure