Monday, 13 February 2017

Exporting App Pools and Websites configuration between multiple IIS instances

Open CMD
Go to this path: C:\Windows\System32\inetsrv
To get AppPool settings
Type: appcmd list apppool /config /xml > c:\apppools.xml

To get WebSite settings
Type: appcmd list site /config /xml > c:\websites.xml

Sunday, 12 February 2017

MVC what is the difference between TextBox and TextBoxFor

  • @Html.TextBox() is loosely typed method whereas @Html.TextBoxFor() is a strongly typed (generic) extension method.
  • TextBox() requires property name as string parameter where as TextBoxFor() requires lambda expression as a parameter.
  • TextBox doesn't give you compile time error if you have specified wrong property name. It will throw run time exception.
  • TextBoxFor is generic method so it will give you compile time error if you have specified wrong property name or property name changes. (Provided view is not compile at run time. )

Thursday, 9 February 2017

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

Module
   IIS Web Core
Notification
   BeginRequest
Handler
   Not yet determined
Error Code
   0x80070021
Config Error
   This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File
   \\?\C:\Program Files (x86)\MyProject\home\web.config
Requested URL
Physical Path
   C:\Program Files (x86)\MyProject\
Logon Method
   Not yet determined
Logon User
   Not yet determined

Config Source:

    3:   <system.webServer>
    4:     <handlers accessPolicy="Read, Script" />
    5:     <directoryBrowse enabled="false" />

More Information:


Solution:

·         Open Control Panel
·         Click on "Turn windows features on or off"
·         Check "Internet Information Services"
·         Check "World Wide Web Services"
·         Check "Application Development Features"
·         Enable all items under this

Sunday, 5 February 2017

The server could not complete your request. For more specific information, click the "Details" button.

The server could not complete your request. For more specific information, click the "Details" button
"Object moved" Error message when you connect to a SharePoint site by using SharePoint Designer 2013
When i try to open SPO site using SPD i got this error...
The server could not complete your request. For more specific information, click the "Details" button.
Object moved
Root Cause: In IIS anonymous authentication for the SharePoint web application that hosts the SharePoint site is disabled.
Solution:
In IIS enable anonymous authentication for the SharePoint web application.

Monday, 30 January 2017

How can I switch my signed in user in Visual Studio

git error we were unable establish the connection because it is configured for user
visual studio 2015 we were unable to establish the connection because it is configured for user
How can I switch my signed in user in Visual Studio 2013?

Try below options...

Option 1:

1. Close Visual Studio
2. Start the Developer Command Prompt from Visual Studio Tools installed with Visual Studio as an administrator.
3. type 'devenv /resetuserdata'  ('wdexpress /resetuserdata' for Express SKUs)
4. Start Visual Studio Normally.


Option 2:

Delete the following key in regedit

hkey_current_user\software\Microsoft\VSCommon\12.0\clientservices\tokenstorage\visualstudio\ideuser

Saturday, 21 January 2017

Sunday, 25 December 2016

Find a string by searching all tables in SQL Server


CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN

    CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))

    SET NOCOUNT ON

    DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110)
    SET  @TableName = ''
    SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

    WHILE @TableName IS NOT NULL

    BEGIN
        SET @ColumnName = ''
        SET @TableName =
        (
            SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))
            FROM     INFORMATION_SCHEMA.TABLES
            WHERE         TABLE_TYPE = 'BASE TABLE'
                AND    QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName
                AND    OBJECTPROPERTY(
                        OBJECT_ID(
                            QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
                             ), 'IsMSShipped'
                               ) = 0
        )

        WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

        BEGIN
            SET @ColumnName =
            (
                SELECT MIN(QUOTENAME(COLUMN_NAME))
                FROM     INFORMATION_SCHEMA.COLUMNS
                WHERE         TABLE_SCHEMA    = PARSENAME(@TableName, 2)
                    AND    TABLE_NAME    = PARSENAME(@TableName, 1)
                    AND    DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar', 'int', 'decimal')
                    AND    QUOTENAME(COLUMN_NAME) > @ColumnName
            )

            IF @ColumnName IS NOT NULL

            BEGIN
                INSERT INTO #Results
                EXEC
                (
                    'SELECT ''' + @TableName + '.' + @ColumnName + ''', LEFT(' + @ColumnName + ', 3630)
                    FROM ' + @TableName + 'WITH (NOLOCK) ' +
                    ' WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2
                )
            END
        END  
    END

    SELECT ColumnName, ColumnValue FROM #Results
END

Then call store proc
exec SearchAllTables '843DE4FEAF494C59A656B4CD4AAB7669'

then delete  store proc and temp tables