Once you installed Sitecore then next step is to create
and map your Visual Studio Web project to Sitecore.
It’s good to install software in sequence of IIS, SQL
Server, Visual Studio and then finally Sitecore.
For this tutorial we will create Welcome page in Visual Studio and show Welcome <Employee Name>
message where Employee Name should
retrieve from Sitecore Content item. Final screen should look like
My Sitecore instance is running at “C:\inetpub\wwwroot\NewInstance2\Website”
and I will create my visual studio project at “D:\MyTestApp”.
So we have all the necessary details. Let’s do mapping now.
Here are steps to map your project with Sitecore.
1.
Create ASP.NET Empty Web Application project
in C# having name like “SitecoreWebApp”
as below
2.
Delete Web.config
file from newly created project.
Add folders like “layouts”, “sublayouts”, “upload” and “xml” to this application.
Add “welcomepage.aspx” page in layouts
folder.
Copy “Sitecore.Kernel.dll” from Sitecore instance [i.e. from C:\inetpub\wwwroot\NewInstance2\Website\bin]
to project bin directory [i.e. to D:\MyTestApp\SitecoreWebApp\SitecoreWebApp\bin]
through file system.
Add reference of this “Sitecore.Kernel.dll” to current project
and set its property CopyLocal = false.
After all these steps your solution
should look like this
3.
Login to Sitecore and create “Employee” template as below
4.
Also create standard values for this
template by selecting Employee
Template -> Select Builder Options
Menu -> Click Standard Values as
below
5.
Enter token in Employee Name field as “$name”
so that content item name should filled by default as below
6.
Create Layout
having name “welcomepage” as below
7.
Create content
item with name “Surendra Sharma”
as below. Check Employee Name field filled automatically as per the item name.
8.
Our content is ready but we need layout to display
this information. So map this content with layout by selecting content item “Surendra Sharma” -> Presentation Menu menu -> Details -> Click Edit link from Default section -> Select Layout
-> Select “Layouts\welcomepage” as
below
9.
Now go to Visual Studio project and design
and code “welcomepage.aspx” page as
below
10. Till
this step we mapped everything. It’s time to publish our Web application from
Visual Studio. So right click your project from Solution Explorer and select Publish. Create profile and select
publish method as “File System”.
Select Target Location as your
Sitecore instance website folder. In my case it is “C:\inetpub\wwwroot\NewInstance2\Website”
as shown below
11. In
next step select Release
configuration only and uncheck
Delete checkbox as shown below
12. After
successful publishing, we can Preview the content item. So select “Surendra Sharma” from content tree
-> Publish Menu -> select Preview as shown below
13. Your
browser should show screen like this
14. Bazinga!!!!
Congrats, if you are reading this line, you successfully mapped your project
with Sitecore.
Please leave your comments or share this guide if it’s
useful for you.