find a location for property in a new city

Monday 22 November 2010

Adding service reference gives the system cannot find the path specified error

I got an "The system cannot find the path specified." error box pop up when I tried to add a WCF web service reference to my web project. Problem with Service References?

Every time I tried to add the service reference to another WCF service I had set up in another web project I kept getting "The system cannot find the path specified." pop up in an alert box in Visual Studio 2010.

Solution

Somewhere along the line I had deleted the "Service References" folder from the project folder I was trying to add the reference to. It is simply solved by creating an new folder (in Windows Explorer) in the correct location called "Service References". Problem solved

Follow britishdev on Twitter

Thursday 18 November 2010

How to host multiple secure sites in IIS

I have two sites: www.site1.com and www.site2.com. Both have pages that are served securely and so need a binding for https on port 443.

The problem is that only one site can be bound to the https protocol and if I disobey that rule I get strange behaviour such as requests for site1 actually serving the page from site1.

How to host multiple secure sites on your local IIS

First, you should know that sites resolve which site to bind to based on:
  • Host header e.g. local.www.site1.com
  • Port e.g. 443
  • IP adress

In this scenario I really just want to change the host headers of the two https bindings for the different sites but IIS won't let me. But I have ways of persuading it...

Step 1:
Navigate your way to C:\Windows\System32\inetsrv\config where you may or may not see applicationHost.config. This is a very mysterious file, it's there but not, sort of. I've found that it can be edited in NotePad (but nothing else(?))

Step 2:
Ctrl+F your way to "443:" and you should find your attempted 443 http bindings. In my case there are two and they both look like <binding protocol="https" bindingInformation="*:443:" /> (Oh yeah they are exactly the same, lets change that.

Step 3:
Change them to <binding protocol="https" bindingInformation="*:443:local.www.site1.com" /> and <binding protocol="https" bindingInformation="*:443:local.www.site2.com" /> respectively.

Job done

If you check in your IIS UI you will notice that you host headers have indeed been set and your sites should now be able to discriminate between the two.

Follow britishdev on Twitter

Static Membership helper class causing problems with MembershipProvider

I was having a problem where after a user changes their password using my custom MembershipProvider it was being updated in the database but didn't seem to be propagating to my application. So if they tried to log in they would be expected to provide their old password even though there was a new password in the database.

It is almost as if Membership didn't particularly care what has changed in the database and it kept on just doing its own thing.

Almost as if Membership is a static class... oh right it is

I thought the Membership was acting as if it was a singleton or something and never going through its constructor which sets a new UserService() to the UserService property (the service which ultimately gets the users' data). Maybe it is something to do with the fact that MEMBERSHIP IS A STATIC CLASS! Of course.

Membership was using my MembershipProvider but only ever instantiating it once due to its static nature so the UserService was keeping the old version even if the data had been edited. My fix was to make sure that the MembershipService property returned a new MembershipService() each time it is called.

So for context I changed this code in MyMembershipProvider:
public MyMembershipProvider()
{
    UserService = new UserService();
}

public UserService UserService { get; set; }

To this:
public MyMembershipProvider() {}

public UserService UserService
{
    get { return new UserService(); }
}

Follow britishdev on Twitter

Wednesday 3 November 2010

Allow self closing tags in TinyMCE

I needed to make a tag self-close when using TinyMCE. It wouldn't allow it though, it kept opening them up again for me even after I edited them in HTML. How difficult can it be to add a tag to this allow self-closing tags list.

Answer: Not very. Even still though it took me a ridiculous amount of time to find out how to allow a new self closing tag. So I thought I'd share my discovery in case anyone else is struggling to find the answer.

I was trying to type in <source src="myVideo.m4v" /> but TinyMCE kept changing it to <source src="myVideo.m4v" ></source>.

Closed setting allows new self-closing tags

Turns out there is a little know closed setting you can set on tinyMCEs init method. I added my source tag to the list like so:
closed: /^(br|hr|input|meta|img|link|param|area|source)$/

Now any source tags are automatically self closing.

Notice I added a load more like img. The others are there by default in the core TinyMCE code so if I were to just put in source, the others (like img) would stop being self-closing. Not cool.

Follow britishdev on Twitter