Tuesday, May 6, 2014

Mostly used powershell command in SharePoint 2013/ SharePoint 2010

Hi Friends,
This blog is about commonly used power shell command used in SharePoint 2013 and SharePoint 2010. I have tested all these commands in SharePoint 2013.

Power shell is executed from SharePoint 2010/2013 management Shell.
è Adding WSP :
ð Farm solution:
               Add-SPSolution -LiteralPath <Path of wsp>
  Eg: Add-SPSolution -LiteralPath c:\contoso_solution.wsp
 
ð Sandbox Solution:
               Add-SPUserSolution –LiteralPath < path of wsp> -site < site ulr>

è Deploy Installed solution
ð Farm Solution:
               Install-SPSolution -Identity <Web part Name.wsp> -GACDeployment
 Eg: Install-SPSolution -Identity contoso_solution.wsp –GACDeployment
 
ð Sandbox Solution:
               Install-SPUserSolution –identity wspfilename.wsp –site <site url>
Eg: Install-SPUserSolution –identity wspfilename.wsp –site <site url>

è Update Existing
ð Farm Solution:
               Update-SPSolution -Identity <wsp name> -LiteralPath <WSP Path> -GACDeployment
 Eg: Update-SPSolution -Identity my.wsp -LiteralPath c:\my.wsp –GACDeployment
 
ð Sandbox Solution:
      Update-SPUserSolution -Identity contoso_solution.wsp -Site http://sitename -ToSolution contoso_solution_v2.wsp
    Eg: Update-SPUserSolution -Identity my.wsp -Site http://sitename -ToSolution myv2.wsp
 
è Uninstall Solution :
ð Farm Solution:
Uninstall-SPSolution [-Identity] <SPSolutionPipeBind> -WebApplication <SPWebApplicationPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <String>] [-Confirm [<SwitchParameter>]] [-Language <UInt32>] [-Local <SwitchParameter>] [-Time <String>] [-WhatIf [<SwitchParameter>]]
    Eg:     Uninstall-SPSolution –Identity http://sitename contoso_solution.wsp
 
ð Sandbox Solution:
Uninstall-SPUserSolution [-Identity] <SPUserSolutionPipeBind> -Site <SPSitePipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]]
 Eg: Uninstall-SPUserSolution -Identity my.wsp -Site http://sitename
 
è Remove Solution:
ð Farm Solution:
Remove-SPSolution [-Identity] <SPSolutionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-Language <UInt32>] [-WhatIf [<SwitchParameter>]]
Eg:  Remove-SPSolution -Identity contoso_solution.wsp
ð Sandbox Solution:
Remove-SPUserSolution [-Identity] <String> -Site <SPSitePipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]]
Eg:  Remove-SPUserSolution -Identity contoso_solution.wsp -Site http://sitename

è Get List of Solution
ð Farm Solution:
                        Get-SPSolution
ð Sandbox Solution:
                        Get-SPUserSolution –Site <site name>

è Install Feature:
ð Farm Solution:
Install-SPFeature [-Path] <String> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <Int32>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchParameter>]]
Eg:  Install-SPFeature -path "MyCustomFeature"

è Enable Feature: The Enable-SPFeature cmdlet enables an installed feature at the given scope.
ð Farm Solution:
Enable-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <Int32>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-PassThru <SwitchParameter>] [-WhatIf [<SwitchParameter>]]
Eg:  Enable-SPFeature -identity "Feature Folder path" -URL http://somesite

è Deactivate Feature:
ð Farm Feature:
Disable-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-Url <String>] [-WhatIf [<SwitchParameter>]]
Eg:  Disable-SPFeature –identity "MyCustom" -URL http://somesite

è Uninstall/ Delete Feature: The Uninstall-SPFeature cmdlet removes the specified feature definition from the collection of feature definitions in the farm.
ð Farm Solution:
Uninstall-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <Int32>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-WhatIf [<SwitchParameter>]]
Eg: Uninstall-SPFeature -Identity "MyCustomFeature"

è Get List of active features: It displays feature name and corresponding ID:
        Get-SPFeature -Site http://SharePointSite/


è To Delete unused web parts from Solution Store: .webpart file is not deleted from web part gallery after executing above commands, user needs to run bellow command to delete (.webpart) from gallery.

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$camlQuery = '<Where><Eq><FieldRef Name="FileLeafRef" /><Value Type="Text">TestgiriWebPart_GiriWebPart.webpart</Value></Eq>  </Where>'
$spQuery.Query = $camlQuery

$site = Get-SPSite -Identity "http://win-ua50t4mr5s4"
$webpartgallery = $site.GetCatalog( [Microsoft.SharePoint.SPListTemplateType]::WebPartCatalog)
$webparts = $webpartgallery.GetItems($spQuery)
$webparts[0].Recycle()

è To get details about the feature and web application: If you are not sure what Web the feature is activated in, run the following:
                Get-SPSite http://SharePointSite/ | Get-SPWeb -Limit ALL | %{ Get-SPFeature -Web $_ } | Sort DisplayName -Unique | FT DisplayName,Id

è Delete Feature:
      Uninstall-SPFeature <Feature ID>

è To See List of solutions in Solution store:
Stsadm  -o EnumSolutions


è Backup and Restore:
ð Backup SharePoint FARM:
            Backup-SPFarm -Directory <BackupFolder> -BackupMethod {Full | Differential} [-Verbose]
Eg: Backup-SPFarm c:\SPBackup\myfarm.bak –BackupMethod Full

ð Backup Site Collection:
Backup-SPSite -Identity <SiteCollectionGUIDorURL> -Path <BackupFile> [-Force] [-NoSiteLock] [-UseSqlSnapshot] [-Verbose]
Eg: Backup-SPSite –identity http://siteName/ -path c:\mysite.bak –force

è Restore Backup
ð Restore Server Farm:
Restore-SPFarm -Directory <BackupFolder> -RestoreMethod Overwrite [-BackupId <GUID>]
Eg: Restore-SPFarm -Directory \\file_server\share\Backup -BackupId 12345678-90ab-cdef-1234-567890abcdef -RestoreMethod new -ConfigurationOnly

ð  Restore Site Collection:
  Restore-SPSite -Identity SiteCollectionURLHere -Path BackupFilePathHere [-DatabaseServer DatabaseServerNameHere] [-DatabaseName ContentDatabaseNameHere] [-HostHeader HostHeaderHere] [-Force] [-GradualDelete] [-Verbose]
Eg:  Restore-SPSite –identity http://mysite  -path c:\myback.bak -force

è SharePoint list backup: To backup SharePoint list we need to use SharePoint management shell
ð  Exporting List
Export-SPWeb http://www.domain.com -itemurl "/Lists/NameList" -path "c:\test.cmp”
ð  Importing List:
Import-SPWeb http://www.domain.com -Path "c:\test.cmp"

Commonly used power shell command:
ð  Removing Web application
            Remove-SPWebApplication -identity http://sitename –Confirm

ð  Delete Web Application Pool
            Remove-WebAppPool  -name ‘applicationPoolName’
ð  Remove Web Application , Content Database and IIS Application Pool
Remove-SPWebApplication http://sitename -Confirm -DeleteIISSite -RemoveContentDatabases
  
Export list:
# specify the site URL to export

$web = Get-SPWeb "http://testsite:9000"

# specify output folder to store exported lists

$path = "c:\ListBackup\"

foreach($list in $web.lists)
 {
 "Exporting " + $list.RootFolder.URL
 Export-SPWeb $web.URL -ItemUrl $list.URL -path ($path + $list + ".cmp") -nologfile
 }

Export-SPWeb http://tawasul/IT/ISC/ -ItemUrl "/Lists/List_Name" -path "c:\ExportISC\List_Name.cmp"
Export-SPWeb http://mysite/sites/KPI/ -ItemUrl "/Lists/" -path "c:\Export_KPI\List_Name.cmp"
è    Re-Indexing SharePoint List:
UPDATE <Content DB>.dbo.AllListsAux set NextAvailableId=1 where ListID='<GUID>'
eg:
UPDATE WSS_RQMS.dbo.AllListsAux set NextAvailableId=1 where ListID='{500440F9-EEFE-4659-9D33-B90F68404DD4}'
è    Adding Column to existing SharePoint List using powershell:
param([string]$workspaceUrl)
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
{
$site = SPSite($workspaceUrl)
$web = $site.RootWeb
$spList = $web.Lists["YourList"]
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text
$spList.Fields.Add("YourColumn",$spFieldType,$false)
$spList.Update()
}
)
To Execute: Save this file in your local drive execute as bellow:
PS C:\Administrator> .\YourScript.ps1 -workspaceUrl "yoururl"
Eg: PS C:\Administrator> C:\MyScript.ps1 -workspaceUrl "http://mymachinename:9000"

è    Create database from power shell:
New-SPConfigurationDatabase [-DatabaseName] <String> [-DatabaseServer] <String> [[-DirectoryDomain] <String>] [[-DirectoryOrganizationUnit] <String>] [[-AdministrationContentDatabaseName] <String>] [[-DatabaseCredentials] <PSCredential>] [-FarmCredentials] <PSCredential> [-Passphrase] <SecureString> [-AssignmentCollection <SPAssignmentCollection>]

è    Changing Site Logo:

$sitename= "http:// dev/sites/SiteName"
$sitelogo= "http:// dev/Site Assets/sitelogo.jpg"
$site=new-object Microsoft.SharePoint.SPSite($sitename)
$web=$site.OpenWeb()
$web.SiteLogoUrl=$sitelogo
$web.Update()
$site.Dispose()

è    Cleanup Deleted Database from SharePoint server:
ð    Display list of all database
Get-SPdatabase
ð    This will list all databases in SharePoint that no longer exist on the database server.
Get-SPDatabase | where {$_.exists -eq $false} :
ð    Remove all orphan database:
Get-SPDatabase | where {$_.exists -eq $false} | foreach {$_.delete()}

è    Get List of Application Pool:
ð    Get list of application Pool:
Get-SPServiceApplicationPool
ð    Delete Application Pool:
Remove-SPServiceApplicationPool-Identity <Name of the application pool>
è    Change Master Page :
$web = Get-SPWeb http://sharepoint
$web.CustomMasterUrl = "/_catalogs/masterpage/seattle.master"
$web.MasterUrl = "/_catalogs/masterpage/ seattle.master"
$web.Update()
è    Get List of Web Application in a Farm:
Get-SPWebapplication
è    Get List of Site collection in a Web Application:
Get-SPWebApplication <WebAppURL> | Get-SPSiteAdministration -Limit ALL| Select url,Title
Eg: Get-SPWebApplication  http:// dev/ | Get-SPSiteAdministration -Limit ALL| Select url,Title
è    List all the Web Application and Site collection and sub sites
Get-SPSite
è    Remove a WebApplication, content database, Application Poo:

Remove-SPWebApplication http://win-2k8-dc7:8081 -Confirm -DeleteIISSite –RemoveContentDatabases
è    To Create new Web Application:

$ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos
New-SPWebApplication -Name "WEBAPP" -Port 80 -URL "http://WebAppqa" -ApplicationPool "WEBAPPApplicationPool" -ApplicationPoolAccount (Get-SPManagedAccount "domain\spadmin") -DatabaseName "WSS_Content_WEBAPPRootDB" –AuthenticationProvider $ap
è    To attached SharePoint content database from one server to another server:
ð    Dismount  database from source server:
Dismount-SPContentDatabase [-Identity] <SPContentDatabasePipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-WhatIf [<SwitchParameter>]]
Eg:
Dismount-SPContentDatabase <database name>
ð    Mount Database to new server:
Mount-SPContentDatabase "<ContentDb>" -DatabaseServer "<DbServer>" -WebApplication http://SiteName
è    Crate Site collection:
New-SPContentDatabase -Name WSS_Content_WEBAPP_TestSite  -WebApplication http://WebApp:8080/
New-SPSite http://WebApp:8080/sites/TestSite -OwnerAlias "domain\sAdmin" -ContentDatabase WSS_Content_WEBAPP_TestSite-Name "TestSite" -Template "PROJECTSITE#0"

Regards
Gireesh Painuly..


Saturday, February 8, 2014

How to Debug Visual Studio Solution in SharePoint

Hi friends, this post about debugging SharePoint solution which are created using Visual Studio 2010 or Visual Studio 2012.
When we create any Visual studio solution for SharePoint and deploy it’s WSP on any environment like QA Environment, Staging and production then some time we require to debug the solution to investigate execution process.
Some time even in Development environment debugging SharePoint site takes much time to reach execution debug point. In such cases we can debug SharePoint solution using IIS process method.
To start debug any SharePoint portal you need to check following things.
 è Check whether your updated solution is deployed in environment (other than Dev Env)
 è Get your latest Visual studio project solution which is deployed in SharePoint site.
Do following step to debug your solution:
iis6.0:
  ð  Run command prompt and navigate to following location:
  c:\Windows\System32>
  ð  Type below command:
     c:\Windows\System32>iisapp.vbs
  ð   Above command will display list of processes id with application pool
  ð  You can easily find the SharePoint portal address with application pool on command prompt.
IIS 7.5:
  ð  Run command prompt and navigate to following location:
    c:\Windows\system32> cd inetsrv
    c:\Windows\system32\inetsrv>appcmd list wp
  ð  Above command will display list of processes id with application pool
  ð  You can easily find the SharePoint portal address with application pool on command prompt.
 è Now go to your Visual studio solution => Debug=>Attach Process
 è Here you will find the list of process id where you need to attach the process id of you SharePoint application pool
 è Once correct process id is attached go to your SharePoint Site and click on the event that you want to monitor.


Related links:
Debug SharePoint Applications 
how to debug sharepoint code 

Happy Debugging 

Sunday, December 1, 2013

The term 'Select-Object' is not recognized as Name of a cmdlet

Hi friends,
This error usually occurs in SharePoint 2013 while running SharePoint 2013 Management Powershell.



This happens due to change in environment variable of “PSModulePath” in windows environment variables
To make it workable you need to perform following actions:
è Log in to the SharePoint Server
è Right click on my computer-> Properties-> Advance System Settings -> Environment Variable
è Scroll your System Variable section-> (PSModulePath) you will find below entry in Variable Value section 
ð  PS Module path:
;c:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules
è append below path in seme line:
;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
è It should look like below:
;c:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
 That’s it, now run SharePoint 2013 management shell as administration and you will not see the error

Happy Configuration.....






Saturday, August 24, 2013

Creating Custom Log Out page in SharePoint 2010/ 2013.

Hi friends,
This post is about how to create Custom Log out page in SharePoint. This customization is required when you implement FBA ( Form Based Authentication) or Mix mode authentication in SharePoint. When FBA is implemented with custom Log-in, it does not clear authentication Cookies automatically so to clear authentication cookies we need to do some customization. This customization is done using custom logout page where some block of java-script code is written:

This block of code also helps to prevent error while logging out using FBA.

Following steps are carried out while creating custom log out page in SharePoint with

1.       First Create a logout.aspx using SharePoint Designer
è Open your site using SharePoint designer-> Go to site pages->click on Page button on top ribbon and select ASPX page.
è It will create an aspx page in site pages rename it to Logout.aspx
è Double click on page, it will open page designer, Check Out the page and click on edit file link to open in edit mode.
è Add page title to: Lout out
è Add bellow Script in <head> section:
<script type="text/javascript">
function LogOutBodyOnLoad()
{
try
{
   /* Note : this command is support with only IE  */
  document.execCommand("ClearAuthenticationCache",false);
  window.close(); // It asks to close browser after logout.
  }
  catch (e) { }
 window.location='/_layouts/signout.aspx'; // Redirects to sign out page of SharePoint.
 }
 </script>
è In <body> section change as bellow:
<body onload="LogOutBodyOnLoad ()">
è Check in your Logout.aspx page after performing above changes.
è Next you need to call this Logout.aspx on click of Log out button on Welcom.aspx page that is master page of your site.
è Before change master page you need to check which master page is used by your application to check it go to Site Action->Site setting-Look and feel->Master page. It will show you which master page is used in your application.
è Go to SharePoint Designer -> click on master page in left navigation -> take copy of your master page. If you are working in SharePoint 2013 then you will get ( oslo.htm, oslo.master, seattle.html and seattle.master). Open only ( .html) page in designer and add below script on head section of master page which your application is using. ( check out your master page before editing )
<script type="text/javascript" src="/_catalogs/Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" >
$(document).ready(function(){$("#zz4_ID_Logout").attr("onMenuClick","STSNavigate2(event,'/Site Pages/Logout.aspx');");});
</script>
è Add jquery fie to _catelogs/Scripts using SharePoint designer. If script folder does not exist in _catelogs crate it and add jqury file in it. Check proper version of jquery file with the master page tag.  Jquery file is added in _catelogs using SharePoint designer.
è If you are using SharePoint designer then Id of Logout control may be different, it may be zz3_ID_Logout or zz4_ …. So to get right ID login to your portal and check Source of page, Search for Log out and get right control ID. Replace control ID in Master page’ javascript tag with the right one.


è That’s it now you can login in to your portal and can identify title of log out page after clicking log out button. This could is mainly written to clear authentication cookies after logout.

That's it.. Fell free to ask any question regarding this post.

Happy Coding 
Regards
Gireesh Painuly..

Sunday, June 9, 2013

Save Site as Template is not visible in Site Settings in SharePoint 


Hi Friends,

This blog is about enabling “Save as Site Template” in SharePoint 2010 and SharePoint 2013.
Save Site as Template is only visible if you have publishing infrastructure disable in your site collection Administrator and site Action.
By default “save site as Template” is visible in Site Settings under <Site Action > In SharePoint 2010 and SharePoint 2013

SharePoint 2013









SharePoint 2010










If “Save as Site Template” is not visible in your Site actions perform following Actions:
1-> First go to your Site settings
  è Site Action -> Manage Site features Click on SharePoint Server Publishing and deactivate it if it is  enabled.
     2-> Site Collection Administrator -> Site Collection Feature (Deactivate following Feature)
  è Cross-Site Collection Publishing    ( optional)  
  è SharePoint Server Publishing Infrastructure
    3-> If you had publishing feature enabled and you have just deactivated it then you will not able to see Save as Site Template after deactivating publishing infrastructure. 
    4-> You need to open your site using SharePoint designer. After opening site using SharePoint designer just go to Site Tab, Site Option button on the right most part of panel, Click on it, a window will open as bellow:





















Happy Codding...

Thanks For Reading....

Gireesh Painuly.


Related Search: 

Enable Save Site as Template in SharePoint 2010
Enable Site as Template in SharePoint 2010.
Site as Template is not visible in Site Settings
Site as Template is not visible in Site Collection  
Site as Template is not visible in Site Action
Save Site as Template Option is Missing in SharePoint 2010.









Wednesday, March 27, 2013

Migrating Asp.Net Application to SharePoint 2010

Migrating Asp.Net Application to SharePoint 2010
Or
Converting asp.net 3.5 Web Application to SharePoint 2010

Hi Friends,
                     This blog is about converting or migrating custom asp.net 3.5 or 4.0 web application to SharePoint 2010.
Scenario: I have an application which was developed in asp.net 3.5 with sql server database. I have a SharePoint Portal where I need to deploy my Asp.net Web application. The main aim is to integrate all the asp.net application that were developed in Asp.net so that all the application can be access using single-sign-on and all application will have single access point in SharePoint.

Solution:  To accomplish this scenario I have first created a SharePoint site collection in a web application then in this web application I have created no of sub sites for each asp.net Web Application so that each application can be separated.

So Steps will as below:

Note: This solution is targeted to SharePoint 2010.
Step 1: Create a Web Application (if you don’t have existing one) from SharePoint Central administrator.

Step 2: Create a Site collection which will be the main entry point for SharePoint Portal.

Step 3: Create sub sites for each web application which you are planning to deploy in SharePoint so that you can link each application from main site.
 -  Now first check your existing asp.net Web application setting and configuration

Step 1:  Go to your Asp.net Web application and check if all the application are using .NET framework 3.5

Step 2: Go to all the application’s (if you have n-tier application) and check that every solution is using .net 3.5 framework.

Step 3: First Create strong key name for all the application dlls which you will copy to SharePoint so every solution in an application require strong key.

  ->  To generate strong key go to Start-> Visual studio 2010(2008)-> Tools -> Visual studio command Prompt. It will open visual studio command prompt.
  -> Type :  sn –k yourdllName.dll  <path of your snk file where you will like to store>
  ->  eg: sn –k mydll.dll C:\mysnk1.snk

Step 4: Now go to your asp.net application select solution one by one ->Project Properties. You will get signing tab click on it. Check sign the assembly checkbox and upload strong key and save.

Step 5: Follow same steps 3 to 4 for all your application to sign with strong key name.

Step 6: Add following line in all the assembly.cs of all layers ( if n-tier): at the top of [assembly attribute]. It allows SharePoint to call these dlls and also allows communication among dlls.

[assembly: System.Security.AllowPartiallyTrustedCallers]

Step 6: Now compile all of your dlls layer by layer and the complete solution.

Step 7: Next you need to copy all the dlls from you asp.net solutions’ bin directory to SharePoint. So you have created a SharePoint Site go to It’s virtual directory.

    -:  If your IIS is installed in C:\ drive then your path may look like below:
    -:  C:\inetpub\wss\VirtualDirectories\8888\bin where 8888 is the port number of my sharepoint site.
    -:  Copy all the dlls to Bin directory

Step 8: Next Open the web.config of your SharePoint portal which will be at your port no 8888 (your port no may differ).
   ->  Add following Tag to web.config file:

<!–Page parser added–>
<PageParserPaths>
<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />
</PageParserPaths>


  ->  Mostly  <PageParserpaths> tag will be there in your web.config file search for it and place above tag in side it.
  ->  Next  you need to register your dlls within safe control section of web.config file go to <SafeControl> section and just press enter , then register your dll one by one here eg below

  <SafeControl Assembly="SPMigration, Version=1.0.0.0, Culture=neutral, PublicKeyToken= 512e23e28e25b338 " Namespace="SPMigration" TypeName="*" Safe="True" SafeAgainstScript="True"/>

      <SafeControl Assembly="BusinessLayer, Version=1.0.0.0, Culture=neutral, PublicKeyToken= f371028fb11feba8 " Namespace=" BusinessLayer " TypeName="*" Safe="True" SafeAgainstScript="True"/>

     - Assembly: Name of your assembly which you have copied in bin directory of SharePoint.

     -  Version: It will mostly 1.0.0.0 but you can check version of your assembly and replace it with correct version.

     - PublicKeyToken: You need to get public key token of your assembly, you can get it by using sn –T <your dll name>. It will display public key token copy it here.

     - NameSpace: It should contain name space which is written in side assembly some time assembly name and namespace is different. So check name space from your asp.net Web application and copy here.

   - Other attribute will remain same as I have written above.
Step 9: If your application contains database connection or any other dll registration which may be there in asp.net’s web.config file needs to be register here also in web.config file of SharePoint Portal. So copy connection string from your web.config to SharePoint portal config in Connection section of web.config same way register all dlls also in this config file.

Eg:
 <connectionStrings>
<add name=”MyCompanyConnectionString” connectionString=”Data Source=PRAVEEN;Initial Catalog=MyCompany;User ID=sa;Password=@System”
providerName=”System.Data.SqlClient” />
</connectionStrings>


Step 10: Now everything is in place, we need to copy our aspx pages in SharePoint site. For this go to your asp.net Application copy only aspx pages not .cs page in a separate folder on your computer.

   - Open your SharePoint site by using SharePoint designer and click on site pages. On top of ribbon bar click on import files and point to your local folder of where you have copied  aspx page. Click on ok button it will import all the aspx pages to SharePoint site page gallery.

 -  Now you need to change Master Page: Attach v4.Master page to these pages by going to Style tab on Ribbon, Click on Attach and select the v4.master as shown here. Select aspx page one by one and apply master page to them.

  -  Now go to source code of all your aspx pages one by one and remove codebehind tag.  

  -  Inheritance tag at tope of page is very important. It may struggle you to get data from your database. So don’t change it because we have registered our dll in web.config just make sure Inheritance=”DllName.CodebehindfileName”

   - If you want to use your master page of asp.net then you need not to use master page of SharePoint just keep the things as it is and put your master page in a web part which is used to display page content and it will work fine.

  -  Now  go to your SharePoint portal (or even you can check your pages in SharePoint designer by browsing page in browser), go to Site pages and click on any page which belongs to your application. You can see it has same look and feel as SharePoint.

That’s It your application is migrated now you can use Authentication of SharePoint and you can also use default permission of SharePoint with your aspx pages.

Note: If you get any issue regarding migration of your asp.net application write your comments or you can mail me at: girish.eng@gmail.com

Related link: 
Migrating asp.net web Application to ShaerPoint 2010
Converting asp.net Web Application to ShaerPoint 2010
Converting Custom asp.net Web Application to SharePoint 2010

Thanks & Regards
Gireesh Painuly
Happy Coding…