 |
BOOK: Beginning ASP.NET 4 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

September 16th, 2010, 10:17 PM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Copy Site to IIS
I've made it to the last chapter and thought I followed all instructions in setting up IIS and copying the files to the Release directory. But when I enter http://localhost in IE8 the page that displays has no theme applied. I can select the login page and when I login I get the yellow screen of death with the message: "An attempt to attach an auto-named database for file C:\Users\Jim\Documents\BegASPNET\Release\App_Data\ aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share"
Any suggestions?
|
|

September 17th, 2010, 02:08 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
>> :\Users\Jim\Documents\BegASPNET\Release\App_Data\ aspnetdb.mdf
Looks like you made a setup error somewhere If you follow along with the book, you store the site in a folder such as C:\BegASPNET\Release and provide access to the IIS account. In your case, it seems the site and database are still under your documents folder where the IIS account and database sevrer have no access to.
A few ways to solve this, depending on your setup:
1. Move the database to something like C:\Databases, attach it to SQL Server and then configure your site to use the database using the Initial Catalog attribute in the connection string. You may still need to move the site in order to let IIS access it.
2. Rely on the AttachDbFileName option, by moving the database back into App_Data (if that isn't the case). For this to work, move the entire site (e.g. the Release folder) outside your documents into a public location such as C:\Websites and assign the right permissions for the account used by IIS.
With regard to the theme: difficult to say. Maybe IIS cannot read the necessary files because of the permissions issue? Can you provide more information about your setup? E.g. IIS version, folder setup, how you mapped the root in IIS and so on?
Cheers,
Imar
|
|

September 17th, 2010, 10:16 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Well that was easy! I just moved the entire BegASPNET folder out of My Documents and put it under C:\. Then made sure the security was set correctly and changed the directory of the default site in IIS.
I no longer get the database error and can login successfully. After entering http://localhost in my browser, the login page appears without any theme. After logging in then all the pages have the monochrome theme as expected. I can change to the dark grey theme also. The themes stay applied no matter what page I move to, so it looks like the only issue is the login page has no theme applied and is not laided out as expected.
(I'm running Windows 7 Ultimate 64-bit. IIS 7.0. I've reviewed the setup on pp 715-716 and all looks good.)
|
|

September 17th, 2010, 10:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Does the Login page inherit BasePage in the Code Behind?
Imar
|
|

September 17th, 2010, 10:26 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Yes, the Login page inherits the BasePage.
|
|

September 17th, 2010, 10:29 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Could it be a caching issue? Otherwise, I don't know why it wouldn't display the theme.. Can you post the markup and code behind for the page?
Imar
|
|

September 17th, 2010, 09:12 PM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Imar - Thanks for the quick responses. (Sorry to reply so late, but I had to go out of town.) Below is my Login.aspx page:
Code:
<%@ Page Title="Log in to Planet Wrox." Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<h1>Log in to Planet Wrox.</h1>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server"
CreateUserText="Sign Up for a New Account at Planet Wrox"
CreateUserUrl="SignUp.aspx">
</asp:Login>
<br />
<br />
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
<MailDefinition Subject="Your New Password for PlanetWrox.com">
</MailDefinition>
</asp:PasswordRecovery>
</AnonymousTemplate>
<LoggedInTemplate>
You are already logged in.
</LoggedInTemplate>
</asp:LoginView>
<asp:LoginStatus ID="LoginStatus1" runat="server" />
</asp:Content>
The Login.aspx. vb page:
Code:
Partial Class Login
Inherits BasePage
End Class
My Default.aspx page:
Code:
<%@ Page Title="Planet Wrox" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<h1>
Hi there visitor and welcome to Planet Wrox</h1>
<p class="Introduction">
We're glad you're <span class="style1">paying a visit</span> to
<a href="http://www.PlanetWrox.com">www.PlanetWrox.com</a>, the coolest music
community site on the internet.</p>
<p class="Introduction">
Feel free to have a <a href="Default.aspx">look around</a>; there are lots of
interesting <strong>reviews and concert pictures</strong> to be found.</p>
<p>You can <a href="Login.aspx">log in</a> here.</p>
</asp:Content>
My Default.aspx. vb page:
Code:
Partial Class _Default
Inherits BasePage
End Class
Further clarification - When I enter http://localhost in the browser, I'm taken to the Login page (without themes) even though default.aspx is at the top of the list in IIS. When I enter http://localhost/default.aspx in the browser, I'm taken to the Default page (without themes). I can click on the Login link and I'm taken to the Login page (without themes). Once logged in, all pages have themes applied.
Thanks again!
|
|

September 18th, 2010, 02:39 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Quote:
|
When I enter http://localhost in the browser, I'm taken to the Login page (without themes) even though default.aspx is at the top of the list in IIS.
|
Aha, this seems to imply a problem with security.
It seems as if you've protected all your pages and thus require users to be logged in on all pages. That in turn prevents users from accessing images and CSS files on the Login fie because they don't have the correct permissions (The Login page behaves differently, ASP.NET always provides access to the Login page regardless the security settings, or you wouldn't be able to log in).
Can you show the code for your web.config? In particular the sections for authentication, authorization, membership and any location elements that may override these settings.
Cheers,
Imar
|
|

September 18th, 2010, 10:22 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 21
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Security is a baffling area to me. (Got a good book on that?!) Here's my webconfig file:
Code:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="FromAddress" value="[email protected]"/>
<add key="FromName" value="Jim Ransford"/>
<add key="ToAddress" value="[email protected]"/>
<add key="ToName" value="Jim Ransford"/>
<add key="SendMailOnError" value="false"/>
</appSettings>
<connectionStrings>
<add name="PlanetWroxConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\PlanetWrox.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
<add name="PlanetWroxEntities" connectionString="metadata=res://*/App_Code.PlanetWrox.csdl|res://*/App_Code.PlanetWrox.ssdl|res://*/App_Code.PlanetWrox.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\PlanetWrox.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<system.web>
<trace mostRecent="true" enabled="false" requestLimit="100" pageOutput="false" localOnly="true"/>
<customErrors mode="RemoteOnly" defaultRedirect="~/Errors/OtherErrors.aspx" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/Errors/Error404.aspx"/>
</customErrors>
<profile>
<properties>
<add name="FirstName"/>
<add name="LastName"/>
<add name="DateOfBirth" type="System.DateTime"/>
<add name="Bio"/>
<add name="FavoriteGenres" type="System.Collections.Generic.List`1[System.Int32]"/>
</properties>
</profile>
<roleManager enabled="true"/>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, 
 System.Web, Version=4.0.0.0, Culture=neutral, 
 PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<authentication mode="Forms"></authentication>
<httpRuntime requestValidationMode="2.0"/>
<pages theme="Monochrome">
<controls>
<add tagPrefix="Wrox" tagName="Banner" src="~/Controls/Banner.ascx"/>
</controls>
</pages>
<!--
<pages theme="DarkGrey" styleSheetTheme="DarkGrey"></pages>
-->
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
<buildProviders>
<add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider"/>
<add extension=".skin" type="System.Web.Compilation.PageBuildProvider"/>
</buildProviders>
</compilation>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="Jim Ransford <[email protected]>">
<network host="smtp.jlransford.com"/>
</smtp>
</mailSettings>
</system.net>
<location path="Management">
<system.web>
<authorization>
<allow roles="Managers"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<location path="MyProfile.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="ManagePhotoAlbum.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="NewPhotoAlbum.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
|
|
 |
|