Wednesday, October 31, 2012

SQL Server Authentication enabling using Microsoft SQL Server 2008 Management Studio

Microsoft SQL Server Management Studio provides integrated environment for accessing, configuring, managing, administering and developing all components of SQL Server. There you can see two authentication modes called "Windows Authentication" and "SQL Server Authentication". The Windows authentication mode only allows you to login/connect to SQL Server with Windows authentication.


If you install the Microsoft SQL Server using Windows Authentication mode, the "sa" account is disabled by default. So if you plan to use SQL Server Authentication, you have to enable the "sa" account. This tutorial tells you how to enable the "sa" account and there you must remember that the SQL Server service needs to restart to make this change effective

1. First, Login to the SQL Server Management Studio using Windows Authentication. Right-click on the database instance, and go to Properties.


2. Then on Properties page, click on Security and select SQL Server and Windows Authentication mode, and click on OK to close the Server Properties page.


3. Now you will get dialog box saying that you should restart your SQL Server to take the changes take effect. Is is not done yet, you have to done one more thing to enable the "sa" login.

4. Now expand Security folder and go to Logins. You can see the "sa" account is disabled when you install SQL Server using Windows Authentication mode.


5. Then right-click on the "sa" account and go to Login Properties. There you can set a password for the "sa" account.



6. Click on the Status page. There you can see the "sa" account is disabled by default. Click on the Enabled button to enable it. Then click on Ok to close the "sa" Login Properties.


Now "sa" account is enabled and you can login to the SQL instance using the "sa" account after restarting the SQL Server.

Allow IIS to access Local SQL Server database


You can change the ApplicationPoolIdentity from IIS7 -> Application Pools -> Advanced Settings.
AdvancedSettings
Under ApplicationPoolIdentity you will find local system. This will make your application run under NT AUTHORITY\SYSTEM, which is an existing login for the database by default.

Tuesday, October 30, 2012

Introducing IIS Express


Developers today build and test ASP.NET sites and applications using one of two web-servers:
  • The ASP.NET Development Server that comes built-into Visual Studio
  • The IIS Web Server that comes built-into Windows
Both of the above options have their pros and cons, and many ASP.NET developers have told us: “I wish I could have the ease of use of the ASP.NET Development Server, but still have all the power and features of IIS”.  Today I’m happy to announce a new, free option that we are enabling – IIS Express - that combines the best characteristics of both, and which will make it easier to build and run ASP.NET sites and applications.
IIS Express will work with VS 2010 and Visual Web Developer 2010 Express, will run on Windows XP and higher systems, does not require an administrator account, and does not require any code changes to use.  You will be able to take advantage of it with all types of ASP.NET applications, and it enables you to develop using a full IIS 7.x feature-set.

How Things Work Today

Before I get into the details of IIS Express, let’s first quickly review how the ASP.NET Development Server and IIS options work today.
ASP.NET Development Server
Visual Studio’s built-in ASP.NET Development Server (also known as “Cassini”) has the benefit of being light-weight and easy to quickly run.  It doesn’t listen on remote ports (which makes it easier to get approved for many corporate security environments), works even when you are running under a non-administrator account, and doesn’t require a separate installation step. 
The fact that it is so easy to get running is a huge positive of it – and the reason it is the default web-server used by ASP.NET projects in Visual Studio when you press F5 to run them:
image
The downside with the ASP.NET Developer Server, though, is that it does not support a full set of web-server features.  For example, it doesn’t support SSL, URL Rewriting Rules (like the SEO URL Rewrite Rules I blogged about here), Custom Security Settings, and other richer features now offered with IIS 7.
IIS Web Server
IIS is the other option developers use when running and testing their applications with Visual Studio.  You can configure a web project within Visual Studio to use IIS by right-clicking on the project and pulling up its properties (and then by clicking on the “Web” tab within the properties window)":
image
Using IIS as your development server allows you to take full advantage of all web-server features (SSL, URL Rewrite Rules, etc).  IIS is a full-fledged web-server – which means you’ll get an experience closer to what it will work like when you deploy the application on a production server.
The downside with using the IIS option today, though, is that some companies don’t allow full web-servers to be installed on developer machines. IIS also requires administrator account access to setup and debug projects.  Different versions of Windows also support different versions of IIS.  For example, if you are running on Windows XP you have to use the IIS 5.1 web-server that comes with it – which doesn’t support all the new features of IIS 7.x.  Configuring a web project within VS to use IIS also requires some extra installation and configuration steps.

IIS Express – The Best of Both Options

We have been working on a new flavor of IIS 7.x that is optimized for developer scenarios that we are calling “IIS Express”. We think it combines the ease of use of the ASP.NET Web Server with the full power of IIS.  Specifically:
  • It’s lightweight and easy to install (less than 10Mb download and a super quick install)
  • It does not require an administrator account to run/debug applications from Visual Studio
  • It enables a full web-server feature set – including SSL, URL Rewrite, Media Support, and all other IIS 7.x modules
  • It supports and enables the same extensibility model and web.config file settings that IIS 7.x support
  • It can be installed side-by-side with the full IIS web server as well as the ASP.NET Development Server (they do not conflict at all)
  • It works on Windows XP and higher operating systems – giving you a full IIS 7.x developer feature-set on all OS platforms
IIS Express (like the ASP.NET Development Server) can be quickly launched to run a site from a directory on disk.  It does not require any registration/configuration steps. This makes it really easy to launch and run for development scenarios.
VS 2010 Integration
We are enabling IIS Express so that it can be easily used with Visual Studio 2010. You’ll be able to configure VS 2010 to use it instead of the ASP.NET Web Server as the default web-server on ASP.NET Projects.  Like the ASP.NET Development Server today, you won’t need to register a site or virtual directory to use IIS Express. It will support the same usage-model as the ASP.NET Development Server today – just with more feature support.
When you press F5 to run an ASP.NET project, Visual Studio can automatically launch IIS Express and use it to run/debug the application (no extra configuration required).  Like the ASP.NET Web Server, IIS Express will show up in your task-bar tray when running:
image
You can right-click and click “exit” on the icon above to quickly shutdown IIS Express.  You can also right-click and pull up a list of all sites running with it, as well as the directory location and .NET versions they are running under:
image
Two cool things to notice above:
1) The “Test Site” we are running, as well as IIS Express itself, live under the c:\users\[username] folder on disk. This enables non-administrator usage of IIS Express and sites – and enables a bunch of scenarios not possible with the full IIS today (including the ability to run IIS Express in both a locked-down enterprise environment as well as a locked-down school shared computer environment).
2) The “Test Site” we are running above using IIS Express supports both HTTP and HTTPS access.  IIS Express automatically installs a “self-signed certificate” and enables URL ACLs and SSL Certificates for ports so that developers (running as non-administrators on a machine) can use SSL without needing to elevate their accounts or setup any additional configuration.  This enables you to configure secure pages within your applications (like Logon forms) for SSL and run/test them at development time just like they’ll work on your real web-server.
IIS 7.x Feature Set
IIS Express is as easy to run and use as the ASP.NET Web Server you are familiar with today.  But because IIS Express is based on the IIS 7x codebase, you have a full web-server feature-set that you can use.  This means you can build and run your applications just they’ll work on a real production web-server.  In addition to scenarios like SSL, you can take advantage of the IIS 7.x URL Rewriter module, Media Extensions, Dynamic Compression, Advanced Logging, Custom Security and other rich modules now available.
In addition to supporting ASP.NET, IIS Express also supports Classic ASP and other file-types and extensions supported by IIS – which also makes it ideal for sites that combine a variety of different technologies.

Summary

We think IIS Express makes it even easier to build, run and test web applications.  It works with all versions of ASP.NET and supports all ASP.NET application types (including obviously ASP.NET Web Forms and ASP.NET MVC applications).  Best of all – you do not need to change any code to take advantage of it.  You’ll be able to optionally use it with all your current projects today.
We’ll be releasing the first public beta of IIS Express shortly. With the beta you’ll be able to right-click on a file-system folder and have IIS Express launch a web-site based on that file-system location. We’ll also be releasing a patch for VS 2010 and Visual Web Developer 2010 Express later this year that will enable you to automatically launch and use IIS Express in place of VS’s built-in ASP.NET Developer Server.  Future versions of Visual Studio will then ship with this functionality built-in.

Re-Register ASP.Net with IIS


Background

Various error conditions during installation or running the VersionOne application may be caused by issues with the ASP.Net setup within IIS. These issues can often be solved by re-registering ASP.Net with IIS to ensure the correct files are recognized by the web server. Use the Procedure below to run the IIS Registration tool.

Process

ASP.NET can be re-registered with IIS. The specific method depends on the operating system being used. For more information on ASP.Net and the IIS Registration tool, see the related links below.
Windows 2000/XP
To fix this on Windows 2000 or Windows XP, run this command from the Start>Run box or a command prompt (assuming the system directory is C:\Windows):
.Net 1.1: C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
.Net 2.0: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
Windows 2003
On Windows 2003, ASP.NET must be both installed and enabled.  To install ASP.NET:
  1. On the taskbar, click the Start button, point to Control Panel, and then click Add or Remove Programs.
  2. In the Add or Remove Programs dialog box, click Add/Remove Windows Components.
  3. In the Components box in the Windows Components Wizard, click the Web Application Server check box, and then click Next.
  4. When the Windows Components Wizard has finished configuring Windows Server 2003, click Finish.
To enable ASP.NET, run this command from the Start>Run box or a command prompt (assuming the system directory is C:\Windows):
.Net 1.1 (32-bit): C:\Windows\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i -enable
.Net 2.0 (32-bit): C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i -enable
.Net 2.0 (64-bit): C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i -enable

How to write to an event log by using Visual C#

This step-by-step article shows you how to add your own entries to the operating system's event log by using the Microsoft .NET Framework.

Requirements

The following list describes the recommended hardware, software, network infrastructure, and service packs that you will need:
  • Microsoft Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, or Windows NT 4.0 Server
  • Microsoft Visual Studio C#

Write to an event log

Event logging provides a standard, centralized way for your applications to record important software and hardware events. Windows supplies a standard user interface for viewing the logs, the Event Viewer. By using the common language's run-timeEventLog component, you can connect to existing event logs easily, on both local and remote computers, and write entries to these logs. You can also read entries from existing logs and create your own custom event logs. In its simplest form, writing to an event log involves only a few steps to create a sample application. To do this, follow these steps:
  1. Open Visual Studio C#.
  2. Create a new Console application in Visual C#. The Console application creates a public class and an empty Mainmethod for you.
  3. Verify that the project references at least the System.dll file.
  4. Use the using directive on the System and System.Diagnostics namespaces so that you do not have to qualify declarations from these namespaces later in your code. You must use these statements before any other declarations.

    using System;
    using System.Diagnostics;
         
  5. To write to an event log, you must have several pieces of information: Your message, the name of the log you to which you want to write (which will be created if it does not already exist), and a string that represents the source of the event. You can register a particular source with only a single event log; if you want to write messages to more than one log, you must define multiple sources.

    string sSource;
    string sLog;
    string sEvent;
    
    sSource = "dotNET Sample App";
    sLog = "Application";
    sEvent = "Sample Event";
         
  6. Use two static methods of the EventLog class to check whether your source exists, and then, if the source does not exist, to create this source that is associated with a particular event log. If the log name that you specify does not exist, the name is created automatically when you write your first entry to the log. By default, if you do not supply a log name to the CreateEventSource method, the log file is named "Application Log."

    if (!EventLog.SourceExists(sSource))
     EventLog.CreateEventSource(sSource,sLog);
         
  7. To write a message to an event log, you can use the EventLog.WriteEntry static method. This method has several different overloaded versions. The following sample code shows the simplest method, which takes a source string and your message, and one of the more complex methods, which supports specifying the event ID and event type:

    EventLog.WriteEntry(sSource,sEvent);
    EventLog.WriteEntry(sSource, sEvent, EventLogEntryType.Warning,  234);
         
  8. Save your application. Run your application, and then check the Application log in the Event Viewer to see your new events.

Complete code listing


using System;
using System.Diagnostics;

namespace WriteToAnEventLog_csharp
{
 /// Summary description for Class1.
 class Class1
 {
  static void Main(string[] args)
  {
   string sSource;
   string sLog;
   string sEvent;

   sSource = "dotNET Sample App";
   sLog = "Application";
   sEvent = "Sample Event";

   if (!EventLog.SourceExists(sSource))
    EventLog.CreateEventSource(sSource,sLog);

   EventLog.WriteEntry(sSource,sEvent);
   EventLog.WriteEntry(sSource, sEvent,
    EventLogEntryType.Warning, 234);
  }
 }
}
    

How to view and manage event logs in Event Viewer in Windows XP

Event Viewer

In Windows XP, an event is any significant occurrence in the system or in a program that requires users to be notified, or an entry added to a log. The Event Log Service records application, security, and system events in Event Viewer. With the event logs in Event Viewer, you can obtain information about your hardware, software, and system components, and monitor security events on a local or remote computer. Event logs can help you identify and diagnose the source of current system problems, or help you predict potential system problems.

Event Log Types

A Windows XP-based computer records events in the following three logs:
  • Application log

    The application log contains events logged by programs. For example, a database program may record a file error in the application log. Events that are written to the application log are determined by the developers of the software program.
  • Security log

    The security log records events such as valid and invalid logon attempts, as well as events related to resource use, such as the creating, opening, or deleting of files. For example, when logon auditing is enabled, an event is recorded in the security log each time a user attempts to log on to the computer. You must be logged on as Administrator or as a member of the Administrators group in order to turn on, use, and specify which events are recorded in the security log.
  • System log

    The system log contains events logged by Windows XP system components. For example, if a driver fails to load during startup, an event is recorded in the system log. Windows XP predetermines the events that are logged by system components.

How to View Event Logs

To open Event Viewer, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, click Event Viewer.

    The Application, Security, and System logs are displayed in the Event Viewer window.

How to View Event Details

To view the details of an event, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, expand Event Viewer, and then click the log that contains the event that you want to view.
  3. In the details pane, double-click the event that you want to view.

    The Event Properties dialog box containing header information and a description of the event is displayed.

    To copy the details of the event, click the Copy button, then open a new document in the program in which you want to paste the event (for example, Microsoft Word), and then click Paste on the Edit menu.

    To view the description of the previous or next event, click the UP ARROW or DOWN ARROW.

How to Interpret an Event

Each log entry is classified by type, and contains header information, and a description of the event.

Event Header

The event header contains the following information about the event:
  • Date

    The date the event occurred.
  • Time

    The time the event occurred.
  • User

    The user name of the user that was logged on when the event occurred.
  • Computer

    The name of the computer where the event occurred.
  • Event ID

    An event number that identifies the event type. The Event ID can be used by product support representatives to help understand what occurred in the system.
  • Source

    The source of the event. This can be the name of a program, a system component, or an individual component of a large program.
  • Type

    The type of event. This can be one of the following five types: Error, Warning, Information, Success Audit, or Failure Audit.
  • Category

    A classification of the event by the event source. This is primarily used in the security log.

Event Types

The description of each event that is logged depends on the type of event. Each event in a log can be classified into one of the following types:
  • Information

    An event that describes the successful operation of a task, such as an application, driver, or service. For example, an Information event is logged when a network driver loads successfully.
  • Warning

    An event that is not necessarily significant, however, may indicate the possible occurrence of a future problem. For example, a Warning message is logged when disk space starts to run low.
  • Error

    An event that describes a significant problem, such as the failure of a critical task. Error events may involve data loss or loss of functionality. For example, an Error event is logged if a service fails to load during startup.
  • Success Audit (Security log)

    An event that describes the successful completion of an audited security event. For example, a Success Audit event is logged when a user logs on to the computer.
  • Failure Audit (Security log)

    An event that describes an audited security event that did not complete successfully. For example, a Failure Audit may be logged when a user cannot access a network drive.

How to Find Events in a Log

The default view of event logs is to list all its entries. If you want to find a specific event, or view a subset of events, you can either search the log, or you can apply a filter to the log data.

How to Search for a Specific Log Event

To search for a specific log event, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, expand Event Viewer, and then click the log that contains the event that you want to view.
  3. On the View menu, click Find.
  4. Specify the options for the event that you want to view in the Find dialog box, and then click Find Next.
The event that matches your search criteria is highlighted in the details pane. Click Find Next to locate the next occurrence of an event as defined by your search criteria.

How to Filter Log Events

To filter log events, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, expand Event Viewer, and then click the log that contains the event that you want to view.
  3. On the View menu, click Filter.
  4. Click the Filter tab (if it is not already selected).
  5. Specify the filter options that you want, and then click OK.
Only events that match your filter criteria are displayed in the details pane.

To return the view to display all log entries, click Filter on the View menu, and then click Restore Defaults.

How to Manage Log Contents

By default, the initial maximum of size of a log is set to 512 KB, and when this size is reached, new events overwrite older events as needed. Depending on your requirements, you can change these settings, or clear a log of its contents.

How to Set Log Size and Overwrite Options

To specify log size and overwrite options, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, expand Event Viewer, and then right-click the log in which you want to set size and overwrite options.
  3. Under Log size, type the size that you want in the Maximum log size box.
  4. Under When maximum log size is reached, click the overwrite option that you want.
  5. If you want to clear the log contents, click Clear Log.
  6. Click OK.

How to Archive a Log

If you want to save your log data, you can archive event logs in any of the following formats:
  • Log-file format (.evt)
  • Text-file format (.txt)
  • Comma-delimited text-file format (.csv)
To archive a log, follow these steps:
  1. Click Start, and then click Control Panel. Click Performance and Maintenance, then click Administrative Tools, and then double-click Computer Management. Or, open the MMC containing the Event Viewer snap-in.
  2. In the console tree, expand Event Viewer, and then right-click the log in which you want to archive, and then click Save Log File As.
  3. Specify a file name and location where you want to save the file. In the Save as type box, click the format that you want, and then click Save.
The log file is saved in the format that you specified.

Tuesday, October 23, 2012

JQuery - BlockUI for Process loading Image

Steps to run Block UI:

Step 1: Copy and add the jquery.blockUI.js in project from the below code
Step 2: Add $.blockUI() to start loading image & $.unblockUI() to stop loading image

Note: We can modify the jquery.blockUI to add our custom messages

What is jQuery BlockUI?

The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAXwithout locking the browser[*]. When activated, it will prevent user activity with the page (or part of the page) until it is deactivated. BlockUI adds elements to the DOM to give it both the appearance and behavior of blocking user interaction.
Usage is very simple; to block user activity for the page:
$.blockUI();
Blocking with a custom message:
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });
Blocking with custom style:
$.blockUI({ css: { backgroundColor: '#f00', color: '#fff'} });
To unblock the page:
$.unblockUI();
If you want to use the default settings and have the UI blocked for all ajax requests, it's as easy as this:
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);