Small Business Starter Kit
Welcome to your new Small Business Site sample application. The key pages are:
·
Catalog Display complete
range of products and services offered by your business
·
News Press room for the business
·
Testimonials Showcase testimonials given by customers
·
People Provide summary and in-depth info about the professionals running
your business
This site is ready to
run! No changes are needed. Press CTRL+F5 to run the site.
Provider
Model
The provider
model is intended to encapsulate all or part of the functionality of multiple
ASP.NET features, such as membership, profiles, and protected configuration.
The Provider model for this website's data access allows the developer to
create data source specific implementations while conforming to an agreed upon
interface. This can be an effective way to:
1. Create an abstraction between the web form code and the data
access layer thus insulating one from changes in the other
2. Support multiple implementations of a feature's functionality
without duplicating the feature code or recoding the application layer if the
implementation method needs to be changed.
The ProviderBase class is simple, containing only a few
basic methods and properties that are common to all providers. Feature-specific
providers (such as NewsProvider)
inherit from ProviderBase and establish the
necessary methods and properties that the implementation-specific providers for
that feature must support. Implementation-specific providers (such as SqlNewsProvider) inherit in turn from a feature-specific provider (in this case, NewsProvider).
The following feature-specific
providers are included in this starter kit
Provider |
Functionality |
CatalogProvider |
Provides data access for categories and items displayed in
Items.aspx |
NewsProvider |
Provides data access for categories and items displayed in
News.aspx |
PeopleProvider |
Provides data access for the people/employees in the small
business |
TestimonialsProvider |
Provides data access for the testimonials to support the
small business |
For each of the 4 providers,
2 concrete implementations are provided out-of-the-box:
1. XML Provider : for data stored in XML files. These are XmlCatalogProvider, XmlNewsProvider,
XmlPeopleProvider and XmlTestimonialsProvider.
2. SQL Server
Provider: for data stored in SQL Server Database. These are SqlCatalogProvider, SqlNewsProvider,
SqlPeopleProvider and SqlTestimonialsProvider
XML
Providers are configured to work by default. This can be changed from the
web.config
Catalog
The catalog data layer provides
ability to have:
·
An arbitrary number of
categories with arbitratry nestings.
·
Items that may belong to
multiple categories
To
add categories and items
For
XML Data Source: Edit the Items.xml file in the App_Data folder
1.
Add an <item>
element at the end of existing <item> elements. It must be under
<items> element. Make sure that all the require sub-elements of the
<item> tag such as <id> <visible> etc are filled.
2.
Ensure that the
<id> is unique among all <item>elements
3.
If no image must be
associated with the new item, then leave the <imageUrl>
element empty. For example: <imageUrl></imageUrl>
4.
Finally, add a <childItem> element with this new item's id under the <category> that this item belongs to. e.g.
<items>
...
<category>
..
..
<childItem>NewItemIdHere</childItem>
</category>
...
</items>
Notes:
1. categories
can be added similarly.
2. items/categories are displayed in the order they are stored in the
xml file
For Sql Server Express Data Source: Add rows to category table
or item table
INSERT INTO Item
(id, visible, title, description, price, inStock, imageUrl, imageAltText,
displayOrder) VALUES ('<id>',<visible:
1|0>, ‘<title>’,'<description', <price>,<1|0>, '<image file url under images/ folder>’, '<image alt text>', <relative display
order used in ORDER BY clause>)
Note: An item may belong
to more than one category.
News
The news data layer
provides ability to exhibit news items relevant to the small business. Concrete
implementations are provided for XML and SQL Server data sources. However
the provider model allows the developer to extend the NewsProvider
class and access news content from any source including RSS.
To
add a news item
For
XML Data Source: Edit the News.xml file in the App_Data folder
1.
Add a <newsItem> element and its sub-elements under the
<news>
2.
Ensure that the
<id> is unique among all <person> elements
3.
If no image must be
associated with the new person, then leave the <imageUrl>
element empty. For example: <imageUrl></imageUrl>
<news>
...
<newsItem>
<id>new id </id>
..
..
</newsItem>
</news>
For Sql Server Express Data Source: Add rows to News table
INSERT INTO News (id, visible,
title, date, [content], imageUrl, imageAltText,
displayOrder) VALUES ('<id>',<visible: 1 or 0>, ‘<title>’, <date-time>, '<content>', , '<image
file url under images/ folder>’, '<image
alt text>', <relative display order used in ORDER BY clause>)
People
The people data layer provides the ability to
display information about the employees of the small business. The provider
model allows the same extensibility for the people data layer as it did for the
news data layer.
To
add a person
For
XML Data Source: Edit the People.xml file in the App_Data folder
1.
Add an <person>
element and its sub-elements under the <perople>
2.
Ensure that the
<id> is unique among all <person> elements
3.
If no image must be
associated with the new person, then leave the <imageUrl>
element empty. For example: <imageUrl></imageUrl>
<people>
...
<person>
<id>new id </id>
..
..
</person>
</people>
For Sql Server Express Data Source: Add rows to People table
INSERT INTO People (id, visible,
firstName, middleName, lastName,title, description, email, phone, fax,
streetAddress, city , state, postalCode, country, imageUrl, imageAltText ,
displayOrder) VALUES ('<id>',<visible: 1 or 0>, ‘<firstname>’, ‘<middlename>’,
‘<lastname>’, ‘<title>’, ‘<description>’, ‘<email>’,
‘<phone>’, ‘<fax>’, ‘<streetAddress>’, ‘<city>’,
‘<state>’, ‘<postalCode>’, ‘<country>’, '<image file url under images/ folder>’, '<image alt text>', <relative display
order used in ORDER BY clause>)
Testimonials
The testimonials data layer provides the ability
to exhibit comments of customers or infuential
persons that support the small business. The provider model allows the same
extensibility for the testimonials layer as it did for the news data layer.
To add
a testimonial
For
XML Data Source: Edit the Testimonials.xml file in
the App_Data folder
4.
Add a
<testimonial> element and its sub-elements under the <testimonials>
5.
Ensure that the
<id> is unique among all <testimonial> elements
6.
If no image must be associated
with the new person, then leave the <imageUrl>
element empty. For example: <imageUrl></imageUrl>
<testimonials>
...
<testimonial>
<id>new id </id>
..
..
</testimonial>
</ testimonials>
For Sql Server Express Data Source: Add rows to Testimonials
table
INSERT INTO Testimonials (id, visible, title, date,
content, testifier, testifierTitle, testifierCompany, imageUrl, imageAltText,
displayOrder) VALUES (<id>, <visible:
1 or 0>, ‘<title>’, <datetime> ,
‘<content>’, ‘<testifier>’, ‘<testifierTitle>’,
‘<testifierCompany>’, ‘<imageUrl>, ‘<imageAltText>’,
‘<displayOrder>’);
Appendix
A - Changing the configuration
1. To add a data access
provider
After implementing a
class that extends one of of the following:
·
CatalogProvider
·
NewsProvider
·
PeopleProvider
·
TestimonialProvider
make an <add ... > entry in the web.config file:
<TestimonialsProviders >
<add name="sqlProvider" type="SqlTestimonialProvider" connectionStringName="SQLConnectionString"/>
name: A given identifier
for the provider. type: The
actual class name of the provider
connectionStringName: The database
connection string used. In case an xml data type is used, the attributes schemeFile and dataFile must be specified.
2. To switch between different data providers, change the provider name in the SmallBusinessDataProviders section
<SmallBusinessDataProviders
peopleProviderName="xmlProvider"
testimonialsProviderName="sqlProvider"
catalogProviderName="sqlProvider"
newsProviderName="xmlProvider"
>
Appendix
B - Publishing Your Site
When you are ready to
share the Web site with others, you can copy it to your Web server. You need to
know the File Transfer Protocol (FTP) address of your server, and if required,
the user name and password assigned to you.
1.
In the Website menu, click Copy Web Site. The Copy Web
Site tool displays the files from your Web site under Source Web Site.
2.
In the Connections list, select Connect to....
3.
In the Open Web Site dialog box, click the FTP Site tab.
4.
Type the FTP address of
your server, and if required, the user name and password that your hosting site has provided. The FTP URL usually has a
format like this:
ftp://ftp.servername/foldername
5.
Click Open. The files on the Web server are displayed under Remote Web Site.
Note:
If you have trouble connecting to the server, contact the server administrator.
6.
In the Source Web site box, select all the files.
7.
Click the Copy selected files from
source to remote web site button.
The
files from your site are copied to the server.
Note
for hosters deploying on a web farm
The
viewstate feature of ASP.NET uses encryption and hashing. Hosters
generally use several servers that may handle asp.net page requests. This can
create issues if server A handled the first request and server B is to handle
the postback, since viewstate was encrypted/hashed using key from server A. Workarounds
to this problem can be found at How
To: Configure MachineKey in ASP.NET 2.0
Appendix C – Setting up SQL Server Database
Database Requirements
• SQL Server 2000, MSDE, SQL Server 2005 or SQL Server 2005 Express
• Query Analyzer or SQL Server 2005 Express Manager April
Instructions
• Install the script to the location of
your choice
• Open Query Analyzer or the SQL Express Manager query editor, then open the
script within it
• Run the script
• Update the <connectionsString> in web.config
Appendix
E - Issues and Workarounds
·
SQL Express Error Message : "Failed to generate a user instance of SQL
Server due to a failure in starting the process for the user instance."
Workaround: Try deleting the folder 'C:\Documents and Settings\[username]\Local Settings\Application Data\Microsoft\Microsoft SQL Server
Data\SQLEXPRESS'
·
SQL Server Error Message:
EXECUTE permission denied on object 'GetRootCategories',
database 'smallcompany_db1', schema 'dbo'.
Run the
following commands to grant permissions:
grant execute on [GetRootCategories]
to public
grant execute on [GetChildItems]
to public
grant execute on [GetNewsItem]
to public
grant execute on [GetNews]
to public
grant execute on [GetPeople]
to public
grant execute on [GetTestimonials]
to public
grant execute on [GetItem]
to public