Hi There,
I am having a problem with the WROX blog app from Chapter 6. I am using Visual Studio 2008 with SP1, and SQL 2005 Express on my dev PC. I am trying to publish to a Win 2003 Server, using SQL Server 2005, and IIS 6.0
I have created the Administrator role in the Blog (ASPNET) DB and added a user to it. When Running locally I can log in and create new blog entries.
On the Server, I have attached the database in SQL 2005 manager and granted the IWAM account Execute privileges for all sp's and ownership of the blog db.
I can login (& out) using the new account I created, but the option to create new entries does not appear.
I then repeated the entire process using a C# version of the Blog that someone had ported from
VB (I'm trying to learn C#), with exactly the same problem.
I put some debug code into the c# version, Default.aspx.cs to write the assigned Role to a label on the blog page:
Code:
protected void Page_Load(object sender, EventArgs e)
{
string[] userRoles = ((RolePrincipal)Context.User).GetRoles();
try
{
lblRoles.Text = userRoles[0];
}
catch
{
lblRoles.Text = "No Roles Defined";
}
}
Which when run locally under VS2008, after logging in the label showed "Administrator", and I am able to create new entries.
However, when running on the server, although I log in, the label shows that "No Roles Defined" and I am unable to create new entries.
Any help would be greatly appreciated.
Web.config below:
Code:
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="DefaultConnectionString" value="SqlServerConnectionString" />
<add key="EmailFrom" value="You@YourProvider.Com"/>
<add key="EmailTo" value="You@YourProvider.Com"/>
<add key="FCKeditor:UserFilesPath" value="/Blog/UserFiles"/>
</appSettings>
<connectionStrings>
<add name="SqlServerConnectionString" connectionString="Data Source=(local);Initial Catalog=blog;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<trace enabled="true" />
<compilation debug="true" strict="false" explicit="true" />
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="SqlServerConnectionString"
enablePasswordRetrieval="False"
enablePasswordReset="True"
requiresQuestionAndAnswer="True"
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
minRequiredPasswordLength="1"
minRequiredNonalphanumericCharacters="0"
/>
</providers>
</membership>
<roleManager enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
defaultProvider="SqlProvider">
<providers>
<add connectionStringName="SqlServerConnectionString" name="SqlProvider"
type="System.Web.Security.SqlRoleProvider" />
</providers>
</roleManager>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx" path="/" protection="All" />
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<customErrors mode="Off" defaultRedirect="ErrorPage.aspx">
<error statusCode="404" redirect="ErrorPage.aspx"/>
<error statusCode="500" redirect="ErrorPage.aspx"/>
</customErrors>
<pages>
<namespaces>
<clear />
<add namespace="System" />
<add namespace="System.Collections" />
<add namespace="System.Collections.Specialized" />
<add namespace="System.Configuration" />
<add namespace="System.Text" />
<add namespace="System.Text.RegularExpressions" />
<add namespace="System.Web" />
<add namespace="System.Web.Caching" />
<add namespace="System.Web.SessionState" />
<add namespace="System.Web.Security" />
<add namespace="System.Web.Profile" />
<add namespace="System.Web.UI" />
<add namespace="System.Web.UI.WebControls" />
<add namespace="System.Web.UI.WebControls.WebParts" />
<add namespace="System.Web.UI.HtmlControls" />
</namespaces>
</pages>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="smtp.YourProvider.com" port="25" />
</smtp>
</mailSettings>
</system.net>
</configuration>