Rick van den Bosch - Blog

... on .NET, software architecture, software development and whatnot

Recent Posts

Tags

News

  • Live space

    Photo blog

    Follow me at twitter

    Rick  van den Bosch

    LinkedIn profile

    Add to Technorati Favorites

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Community

Email Notifications

Blogs I read

Interesting links

Archives

April 2005 - Posts

Configuring an ASP.Net app for multiple login locations with forms authentication

The title isn’t descriptive enough for this post, but it will have to do. Today I was trying to get an ASP.Net application to allow me to define two different login levels. What I was trying to do was the following:

 

There’s a main ASP.Net application, which is allowed to be accessed by anyone (<allow users=”*”>).(http://www.domain.com/)

There’s a customer part where a login is required. (http://www.domain.com/customers/)

There’s a maintenance part where a different login is required. (http://www.domain.com/maintenance/)

 

Because I didn’t want to share my DAL between two applications and I wanted to keep everything within one solution (one project even) I was searching for a way to make sure only the maintenance user would be able to login to the maintenance part but both the maintenance user as well as all the customers would be able to login to the customer part. Especially for these kind of wishes, the <location> element in web.config seems to have been invented. I finally solved the case by defining my web.config as follows:

 

<configuration>

  <!--Default settings for the application (snipped some stuff here)-->

  <system.web>

    <authentication mode="Forms">

        <forms name="UniqueCookieName" loginUrl="login.aspx" />

    </authentication>

    <authorization>

      <allow users="*" />

    </authorization>

  </system.web>

 

  <!--Settings for the maintenance part-->

  <location path="maintenance"> 

    <system.web>

      <authorization>

        <allow users="maintenance_user" />

        <deny users="*" />

      </authorization>

    </system.web>

  </location>

 

  <!--Settings for the customers part-->

  <location path="customers"> 

    <system.web>

      <authorization>

        <deny users="?" />

      </authorization>

    </system.web>

  </location>

 

</configuration>

 

As you can see, I’ve configured the application so that the maintenance-user is the only user that is allowed inside the ‘maintenance’ folder. All other users are denied access. By the way, allowing the maintenance user must happen before denying all the others, or else no-one has rights there.

 

Within the customers location, anyone who logs in is allowed. So everybody who’s unknown is not allowed to do anything.

 

This was my fairly simple solution to what I thought would be something of a challenge…
Visual Studio Powertoys!

I stumbled upon a great workspace at GotDotNet: Visual Studio Core Community Powertoys. Here you can find some pretty neat powertoys for the Visual Studio IDE. For example:

Go Back Visual Studio Add-In
The Go Back Add-in provides a Navigate Backward functionality that is different than the normal Navigate Backward functionality. (Which does some neat things like close a file if you happened to have opened it while navigating forward)

VSMouseBindings
You have a 5 button mouse, why not be able to assign all five mouse buttons to commands within visual studio?

Read Blogs Without Leaving Visual Studio
This open source plugin ships as part of SharpTools 2.0 and is a full-featured RSS / Blog aggregator which integrates into the familiar dockable panes of the Visual Studio.NET IDE.

So, are you interested in using (or making!) Visual Studio Add-Ins? Check out the Visual Studio Core Community Powertoys workspace at GotDotNet.

Posted: Apr 28 2005, 11:53 AM by Rick van den Bosch | with no comments
Filed under:
Regular expression tools
At the Powertoys WebLog, Sara Ford posted about a very cool tool which is available at gotdotnet: Regex Builder.

At gotdotnet it is described as follows: “A tool for building and testing Regular Expressions. It allows you to manipulate the expression and your source text, and shows you a tree with all of the Matches, Groups, and Captures found in the text.”

I think this tool is easier to use for RegEx beginners than for instance The Regulator, because its GIU is pretty simple and there’s some standard information available at startup. The Regulator might scare you off by offering a fairly complex GUI. For more experienced users I’d recommend The Regulator. With this tool you can even search RegexLib.com.

A few other cool features The Regulator offers: code generation and the possibility to compile your regular expression(s) to an assembly!
Internet Explorer 7 - Beta
Last friday Chris Wilton posted about IE7 Beta on the Microsoft Internet Explorer Weblog (IEBlog). The two most important features for IE 7:

- Support for the alpha channel in PNG images.
- CSS standards compliance!

Furthermore, it's nice to know not only Visual Studio 2005 will be released this summer...

[quote]
“... when we release the first beta of IE7 this summer.”
[/quote]
Wanna see my star?
Questa star-listed me on his blog (together with Frans Bouma!). He wrote: “De blog van Gump is nog jong, maar tot nu toe voor mij in iedergeval al de meest gelezen weblog” which roughly translates to “Gump's blog is still young, but is the blog I recently read most.“

I'm flattered Questa: thanks! I'll try to keep up the good work and live up to my star status. ;)
My first BIG Visual Studio 2003 crash - Update

The last couple of years I've had small Visual Studio crashes, where Visual Studio stopped and asked me if I wanted to restart and reopen the current project. These crashes never meant a loss of work. Today I had the first BIG VS2K3 crash and this time it did cost me. A lot...

I'm wondering why VS stopped responding completely. The network here at our client isn't that fast this morning, but I can not imagine this being the problem. I installed ReSharper a couple of days ago, but I would think a lo of people use this. So I don't think that's it either, because I couldn't find anything on their site (only for (much) older versions). Then what was it? A hardware failure? A rare VS bug / feature? Too many heavy apps opened? I don't know. But I do know I will be CTRL-S'ing more often...

Update:
It does seem to be a bug. The problem occured again, at exactly the same place it did half an hour ago. There's one method in my Workflow which (ReSharper) Intellisense does not like too much. And when I complete the method call without Intellisense I don't have Intellisense at all for the workflow object. When I reboot Visual Studio after saving the method that caused this problem, all's well and I can continue my work.... Strange stuff.

Visual Studio .Net 2005 - Beta 2
Sure, I'm not the first one to blog about it. But I still didn't want it to go unnoticed... Visual Studio .Net 2005 Beta 2 is out now. (Available for people with MSDN subscriptions).
For those of you who don't have an MSDN subscription, the Express Editions can give an idea of the power .Net 2.0 will bring to you.

The first impressions of people around me are good. Better yet, those first impressions are VERY good. I'll be installing beta 2 on my Virtual PC shortly and will come back to you with more info...
.Net Refactoring
Most of you probably know about the refactoring options Visual Studio 2005 will deliver to us. For those of you who would like to experience what refactoring, using optimization, partial code generation and more feels like without waiting for VS2K5, you should try JetBrains' ReSharper. I installed it yesterday (after have downloaded it a few weeks ago) and it's a great addition to the Visual Studio development environment.

And having experienced this, I want VS2K5 to come out even sooner....
Datagrid revised
Dino Esposito wrote an excellent article on the new and improved DataGridView control in .Net 2.0 in the .Net magazine of April this year. It explains the possibilities the newly built gridcontrol gives you. Finally a decent grid control...

Curious what .Net 2.0 will bring you? This is a must read!
Posted: Apr 09 2005, 01:46 PM by Rick van den Bosch | with no comments
Filed under:
Source code control for Visual Studio 2005

The hype surrounding Visual Studio 2005 almost makes you not notice all the other upcoming Microsoft developer products which will accompany VS2K5. One of these products is the new source code control system. This January at the ASP.Net 2.0 roadshow in Amsterdam, Scott Guthrie (leading engineer on the ASP.Net 2.0 team) described the new source code control system as ‘SourceSafe done right’.

Microsoft will be delivering Team Foundation which not only will allow you to add source control to your solutions, but also makes it easier to track work items as their status is available at all time. Integration with common Office applications like Project and Excel make it easy to get an overview of the current status for a project.

A quote, taken from “
Visual Studio 2005 Team System: Enterprise-Class Source Control and Work Item Tracking” (link):

Visual Studio Team Foundation includes an enterprise-class source control provider that picks up where Visual SourceSafe leaves off. It is reliable, scalable, fast, more securable, extensible, and includes almost all of the easy to use Visual SourceSafe features with which you and your team are already familiar.

The Visual Studio Team Foundation source control provider ships as a standalone SCM application or as an integrated change management component in Visual Studio 2005 Team System. Inside Visual Studio, the Team Foundation source control plug-in reduces the complexity of source control by making it an extension of project file management. Developers can perform all source control operations without ever leaving the integrated development environment (IDE) or opening another application.
Inside or outside Visual Studio, the Team Foundation source control provider seamlessly integrates with other Team System components such as work item tracking and reporting.


Source Control Provider Description
Implemented as an ASP.NET Web service, the Visual Studio Team Foundation source control provider enables you to access and manage your source-controlled configuration items from anywhere on the Internet.
Source files and project metadata are stored in a Microsoft SQL Server database. Source control operations are performed in an atomic and transactional way. This architecture has the following advantages:
·          Scalability: Given sufficient hardware, your source control repository can contain over a terabyte of data.
Team Foundation supports between five and 500 users.
·          Integrity and Reliability
: The types of data integrity issues associated with file-based source control applications are practically eliminated.
·          Speed
: Depending on the operation requested, Team Foundation is orders of magnitude faster than Visual SourceSafe.

But what about SourceSafe? I use that at home!
Microsoft is updating the version control technology of Visual SourceSafe. A new product release with a continued focus on version control, Visual SourceSafe 2005, will update and improve this popular system. For individual developers or small teams who need a lightweight, client-only, file server application for source code control only, Microsoft will continue to enhance and support Visual SourceSafe. Visual SourceSafe 2005 will include enhancements such as remote web access over HTTP, LAN performance booster, Unicode and XML support, and regional time zones and languages.

Posted: Apr 08 2005, 11:09 AM by Rick van den Bosch | with no comments
Filed under:
Access 2003 now SourceSafe enabled
If you’ve ever worked with Access XP or earlier in combination with SourceSafe 6 and are now using Access 2003, you might miss the SourceSafe capabilities in Access. Out of the box, Access 2003 did not support putting your Access stuff in Sourcesafe. Microsoft has now released an Access 2003 add-in for this! So, if you would like your Access 2003 program to be taken into source code control: it now can. The add-in can be found here.
Internal MS coding guidelines

Brad Abrams posted the internal MS Coding guidelines on his blog earlier this year.
Interesting reading stuff!

I tested my own code against these guidelines. I think I would pass.... ;)

Converting string to enumeration value

Questa posted a very usefull piece of code...
It's possible to convert a string representation of an enum back to an enum!

  private enum MyEnumeration
  {
      FooBar,
      Foo,
      Bar
  }

  ...

  MyEnum foo = MyEnum.Foo;
  string foobar = foo.ToString();
  MyEnum bar = (MyEnum)Enum.Parse(typeof(MyEnum), foobar);

At the end of this code, the variable 'bar' has the MyEnum value 'Foo', just the way it's supposed to be...

"Object does not match target type" error calling a method on an assembly loaded using reflection

Actually, the cause for this error is very small and simple. But because the error doesn't clearly state what's wrong and there's not a lot to be found about this, I'll post it here anyway... Otherwise, you might be looking for this for a while, while it's so easy!

When you are loading an assembly using reflection and you want to call a method from the class that's in the loaded assembly, you might get the error “Object does not match target type”. Even when the method is void and takes no parameters this error can occur. In that case: make sure the methods in the assembly you loaded are static.

Yes, I did have this error myself and yes, I found out the static-part myself eventually. But it took me half an hour. Let's just say it was at the end of a very, very long day..... ;)