Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

Putting up a Web Store SandBox with ASP.NET 2.0


:P
On this page:

Last night I finally got a little spare time to put up a SandBox version of the West Wind Web Store on the Web site. The SandBox is meant to be an open sample that people can play around with faux-shopping experience with faux-payments and items and have access to the full admin interface. Here's your chance to break shit ...

 

This is the same West Wind Web Store running here on the site, just adjusted to allow access to the Admin interface, so people can see the setup forms as well as order and inventory management.

 

It’s one of those things that I should be scared of, right? The Admin functionality has a ton of functionality that has potential for violating application security in a variety of ways. So how do you best set up a locked down ASP.NET application?

 

Here are some things that are important:

 

  • Run the app in a separate App Pool (W3k)
  • Create a new account for this App Pools Identity and minimize the rights
  • Allow Read access only to this account in the app directories
  • Allow Write access ONLY as required (Log file)
  • Create a new database user for the app
  • Assign the user only to that database – no rights elsewhere
  • DataReader/DataWriter access to the database and stored procs as needed.

 

So much for external configuration. What else am I not thinking for?

 

For the SandBox this seems sufficient. In a live application I usually modify this to add the ability to have access to the Admin section of the site via Impersonation. This gives the ability for an Adminstrative user to elevate the rights and allow additional access to certain features such as the ability to write configuration settings in web.config when updated.


Selective Application Level Security

As far as the application goes I added a simple Configuration.DemoMode property to my Configuration class and this demo mode option disables and hides a few fields on a few forms (such as the connection string) as well as not allowing a few tasks. The basic configuration forms etc are not actually accessible.

 

A few deployment issues with ASP.NET 2.0 Beta 2

The West Wind Web Store here has been running on Beta 2 of ASP.NET 2.0 for a while now, so this was another exercise in deploying an application to a live Web Site. This time around the process was a whole lot smoother given advance knowledge of the compilation model issues etc. and using my compiler front end tool with preconfigured settings from the full store. I’m still really unhappy about the way deployment works with ASP.NET 2.0. First time deployment works well but subsequent deployment really bites.

 

For this site I changed the deployment model slight and chose Updateable ASPX pages, because I use the same code version as the main store on the site here, but have a few custom page templates like the Default page. In this scenario a complete pre-compiled page where the ASPX page code gets precompiled simply wouldn’t work well unless you keep two separate Web Project directories. Using the Updateable option is about as close as you come at this point to 1.1 style deployment (though not quite).

 

Using the –u switch on the ASP.NET compiler makes a compiled site updateable meaning the ASPX pages retain their code. By default the compiler generates one assembly per directory plus separate assemblies for App_Code and Global.asax, which reduced the amount of deploy BIN directory files to 6 for my Web application itself (plus 5 more for my various dependent assemblies for bus objects, tools, controls etc.), which eliviates some of my previous complaints about the gazillion files an ASP.NET precompile generates.

 

But the filenames are unique and they change on every compile. And if you leave the old files there, your app won’t run because there will be naming conflicts apparently. If you leave the old files there you get this lovely error:

 

/webstoreSandBox/admin/default.aspx

The type 'Westwind.WebStore.admin' is ambiguous: it could come from assembly 'd:\westwind\WebStoreSandBox\bin\App_Web_g2dja8a_.DLL' or from assembly 'd:\westwind\WebStoreSandBox\bin\App_Web_6nesp30n.DLL'. Please specify the assembly explicitly in the type name.
on 8/2/2005 3:20:04 am

 

So now the rule is:

 

  • Delete the old App_*.* files
  • Copy the new App_*.* files in
  • Copy any modified ASPX pages manually

While not optimal I think out of all the compiler options this seems to be the most manageable.

 

Incidentally last night in setting all of this up I managed to kill the WebLog which – ooops – uses the same logon information as the full West Wind Web Store. In my setup of the Sandbox I also went back and adjusted security on the main West Wind Web Store application reducing the security way down and changing the password. Unfortunately I forgot that I used the same account for the .TEXT WebLog running here which brought the site down all morning until somebody was kind enough to point out my error

 

Still all things considered I was pretty happy with this deployment. All told it was a 1 hour install between installing the Web App ( that’s the easy part – it only takes a few minutes ),  setting up the custom database permissions, removing some sensitive material from the database, customizing a few of the pages, redeploying and adding some extra security. Not bad – it should be even faster next time around…

 

 


The Voices of Reason


 

Bob Archer
August 03, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Isn't there a -fixednames switch on the compiler that will retain the same names from comile to compile?

justin graf
August 03, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

how about fixing the 999 limit on items to be ordered.

justin graf
August 03, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Hey found a bug can't update qty in shopping cart in IE or firefox.

Just a suggestion sense some of my customers have complained about it. When in itemList_Abstract.aspx pages they don't see how to go to another page because it appears at the bottom and to the far right. I think it makes sense to copy other websites and add next>> <<pre, move the number of pages to the center and place it on the top and bottom of the page. Sense in my experience it seems that people are just plain blind.

I love what see

Tim Haines
August 03, 2005

# Steve Eichert offers a new perspective on the blogversation


Rick Strahl
August 03, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Bob,

-fixednames indeed keeps fixed names but when you do that every page compiles into its own assembly which means something like 90 files for this app. I don't like that from a deployment aspect - it takes too long.

Justin - thanks for the pointer on the Cart item bug. Fixed now. As to the Qty limit - you can widen the Qty field in the wws_lineItems and wws_tLineItems tables. Done on this end for the next release.

Rob Bazinet
August 04, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Rick,

I have been working with the VS 2005 Beta 1 & 2 for quite some time now but have yet to produce a live product yet. I have a couple web apps and windows services that will be in production in the next few weeks. All of our work happens on our desktop development environments and have yet to push to a staging server.

So...I am curious if you can point me to some references for what you call "compilation model issues" and that "First time deployment works well but subsequent deployment really bites". How is deployment in 2.0 so much differnet than 1.1??

What method do you use/recommend for deploying applications? Do you use a build tool such as Nant to do these things?

-Rob

suyog
December 09, 2005

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Hi users I am very inexperienced programmer in C#.NET..
I have modified some code in paypal shopping cart which was already developed..but not yet deployed..
I am using sandbox as a test environment in Shopping Cart so obviously have to use certificate for authentication. Now while deploying this project what changes I will have to do in paypalctrl.ascx.cs code..which checks for the authentication..Plz help me for the deployement


Nathaniel Irvin
May 25, 2006

# re: Putting up a Web Store SandBox with ASP.NET 2.0

Hi; if you're anything like me, you get precious little praise, so let me just say this article helped me figure out a particularly annoying problem I was having, so thank you

Rick Strahl's Web Log
October 19, 2006

# Configuration File Settings and ASP.Net Security - Rick Strahl's Web Log

Somebody brought up a good point about my Configuration Settings class today that I failed to mention in the article: Security requirements for an ASP.Net application to be able to actually make changes to the .Config file.

# DotNetSlackers: Putting up a Web Store SandBox with ASP.NET 2.0


Lord Jacob
March 29, 2007

# I'm going to kill my VB Project

I'm so tired... 3 weeks working with this project, i worked at VS2003, and at the time to change my project, it fails by the next "beautiful" error:

2Parser Error Message: The type 'itsoluciones.Global' is ambiguous: it could come from assembly 'c:\inetpub\wwwroot\Fersinsa\itsoluciones\bin\itsoluciones.DLL' or from assembly 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\fersinsa_itsoluciones\1b3e542a\9a1d905d\App_Code.oebhw_wt.DLL'. Please specify the assembly explicitly in the type name."

I can't delete my app_code because i have a module named "variables", and i ca'nt move it...
i'm really tired

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024