Posts

Showing posts from 2012

Connect to SSMS through other domain-user's Windows Authentication

Usually we have only two options to run the SQL Server Management Studio (SSMS): 1. Windows Authentication 2. SQL Authentication Ofcourse everyone knows this :) Obviously, Windows Authentication works with currently logged-in user. But sometimes, we need to run SSMS with other domain user i.e who had little more permissions than us. To do so the trick is to Create a shortcut for SSMS as follows: C:\WINDOWS\system32\ runas .exe /user: DOMAIN-NAME\USERNAME /netonly "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ Ssms.exe " Provisw domain and username of the user specifically. While opening SSMS, it opens command prompt and concern user's password to be entered. Thats it, now we can have SSMS opened in another user's Windows Authentication mode. Hope it helps you too.

Load IIS configured web projects while IIS is not installed in your system

Hi Guys.. There could be situation where web applications would be created under IIS and while opening the projects if IIS is not configured or respective virtual directories are not created then we encounter with following error message: The Web Application Project XXXXXXX is configured to use IIS. The IIS Web server is not installed on this computer. Solutions: 1. If IIS is installed then create a virtual directory and reload the project. 2. If IIS is not installed in your system , then open the respective .csproj/.vbproj in notepad and modify an XML attribute. i.e. Modify from <IISUrl> to <CustomServerUrl> E.g. < IISUrl > http://localhost/MyWebPrj</IISUrl> to < CustomServerUrl > http://localhost/MyWebPrj </CustomServerUrl> Now, reload the project. From now on it will work through file system. i.e. http://localhost:xxxx/MyWebPrj where xxxx = port no. Hope it helps you. Cheers.

Return user control from web service and performance boost details

Great article from Encosia. 1. Boost ASP.NET performance with deferred content loading 2. Creating usercontrol and adding to page control at server from web service method and returning it to consumer. http://encosia.com/boost-aspnet-performance-with-deferred-content-loading/

Parsing of XML in C# - 5 ways

Parsing of XML in C# - 5 ways 1. Using XmlTextReader class 2. Using LINQ to XML methods 3. Using the XmlReader.Create Method 4. Using the XmlDocument.GetElementsByTagName Method 5. Using Dataset and DataTable Object For detailed explanation please refer http://www.aspfree.com/c/a/C-Sharp/5-Ways-to-Parse-XML-in-C/

Test & Debug WCF service using WCFTestClient.exe

Image
VS.NET 2010 provides WCFTestClient.exe for us to test and debug the WCF service.  Please follow me to test and debug the service. Generally, first debug and then test the service, but here first I will tell you how to test it and then how to debug it J Test the WCF service using WCFTestClient. 1.        Open “Visual Studio Command Prompt (2010)” 2.        Go to “c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\” 3.        Run WcfTestClient.exe 4.        It will open WCF Test Client, now add WCF Service (URL) 5.        Select the service method, from left panel 6.        Provide request data (i.e. values to parameters) on right panel and click on Invoke button. It gives you the response. Debug the WCF service, follow the commands. 1.        Go to WCF service project properties 2.        Go to Web menu on left menu 3.        Select WcfTestClient.exe from “c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\” for “Start external progr

Alternate to Dynamic SQL for Search SPs

Today had a chance to work on ‘Search’ functionality using SQL Server stored procedure. Usually we write dynamic SQL in stored procedure for ‘Search’ing purpose. End user might consider few or all attributes as search criteria. To execute the SQL statement, we use sp_executesql We have an alternate to dynamic SQL, using simple select query. Below is the sample. Dynamic SQL Sample: CREATE PROCEDURE [SearchOffcie]      (   @OfficeName VARCHAR ( 100 )         , @OfficeType VARCHAR ( 50 )         , @Address1 VARCHAR ( 100 )         , @Address2 VARCHAR ( 100 )         , @City VARCHAR ( 50 )         , @State CHAR ( 2 )         , @OfficeTypeID INT         ) AS            BEGIN       SET NOCOUNT ON       DECLARE @SqlQry NVARCHAR ( 4000 ) = ''           DECLARE @WhereCondition VARCHAR ( 200 ) = ''           DECLARE @SearchCriteria VARCHAR ( 200 ) = ''           -- Criteria        BEGIN         

Anti ForgeryToken in ASP.NET MVC

To prevent Cross-Site Request Forgery (CSRF) in ASP.NET MVC applications we use AntiForgeryToken () helper. Before that, we’ll have a look on how CSRF works Imagine you have an ASP.NET MVC’s controller class as follows public class UserProfileController : Controller {     public ViewResult Edit () { return View (); }        public ViewResult SubmitUpdate ()     {         // Get the user's existing profile data (implementation omitted)         ProfileData profile = GetLoggedInUserProfile ();         // Update the user object         profile . EmailAddress = Request . Form [ "email" ];         profile . FavoriteHobby = Request . Form [ "hobby" ];         SaveUserProfile ( profile );         ViewData [ "message" ] = "Your profile was updated." ;         return View ();     } } This is all very normal. First, the visitor goes to  Edit() , which renders some form to let them change their user profile det