Wednesday, July 07, 2010
If you ever get into the situation where you've set up Roles, Users etc. on a machine and then script the database over to another machine, and suddenly the users can't login or aren't in the roles they should be - make sure you have specified the applicationName property in BOTH the membershipProvider and roleProvider sections in the web.config.

http://weblogs.asp.net/scottgu/archive/2006/04/22/Always-set-the-_2200_applicationName_2200_-property-when-configuring-ASP.NET-2.0-Membership-and-other-Providers.aspx

Wednesday, July 07, 2010 1:30:21 PM (GMT Standard Time, UTC+00:00) | Comments [0] | ASP.NET#
Tuesday, June 29, 2010
If we have a varchar column as a Primary Key (don't ask - we also are not able to alter the schema) then we can still use Max to generate IDs programmatically.

However, because the column is char, then SQL Server will determine that '9' is actually greater than '1','0' [10] so we need to be a little bit smarter.

Use this:

1. DECLARE @Length INT
2. SET @Length=(SELECT MAX(LEN(ID)) from test)
3. SELECT TOP 1 ID FROM Test WHERE LEN(ID)=@Length ORDER BY ID DESC

Thanks to
http://www.dotnetspider.com/forum/192995-Can-we-apply-Max-function-SQL-Query-for.aspx

And if you want to call this using LINQ to SQL (or variant thereof), you could try:

CREATE PROCEDURE web_GetMaxCampaignCode
(@maxcode int output)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

  DECLARE @Length INT
  SET @Length=(SELECT MAX(LEN(campaign_code)) from ref_campaign_code)
  SET @maxcode = (SELECT TOP 1 campaign_code FROM ref_campaign_code WHERE LEN(campaign_code)=@Length ORDER BY campaign_code DESC)
END
GO


Calling Code:


public static string GetFirstName(int id)
{
using (MyDataContext dataContext = new MyDataContext())
{
string FirstName;
var query = dataContext.GetFirstName(id, ref FirstName);
return FirstName;
}
}
Then just drag your sproc onto the dbml and call it like above.

Tuesday, June 29, 2010 1:26:15 PM (GMT Standard Time, UTC+00:00) | Comments [0] | Database#
Saturday, June 05, 2010
Using Apache's mod_rewrite, we can move requests from an old domain to a new one very easily.
Saturday, June 05, 2010 11:43:07 AM (GMT Standard Time, UTC+00:00) | Comments [0] | Web Design#
Wednesday, June 02, 2010
A nice example of using Windbg to get to the root of a problem:

http://blogs.technet.com/b/markrussinovich/archive/2010/06/01/3335060.aspx

Wednesday, June 02, 2010 2:14:51 PM (GMT Standard Time, UTC+00:00) | Comments [0] | #
Friday, May 28, 2010
Building your first REST service in ASP.NET
Friday, May 28, 2010 4:11:44 PM (GMT Standard Time, UTC+00:00) | Comments [2] | ASP.NET | wcf#
Thursday, May 27, 2010
Turns out this was a Facebook bug after all.

We switched the Firewall back to the way it was, without changing the code, and hey presto - all is well.

Not only that but the second step (email invites) was not displayed.

FB - All your base are belong to us.

Thursday, May 27, 2010 9:06:04 AM (GMT Standard Time, UTC+00:00) | Comments [0] | Facebook#
Wednesday, May 26, 2010
Right this way - http://codezest.com/archive/2008/09/06/fiddler-firefox-local-web-site-testing-easily-foxyproxy.aspx

Using Fiddler with Firefox for Local Web site Testing Easily with FoxyProxy

Technorati Tags: ,

 

Fiddler is one of the best tools to analyze web requests sent from a web site and much more. Normally, using Fiddler with FireFox is a huge pain and typically does not work well out of the box when testing localhost requests or any requests for that matter with Fiddler through Firefox.   But by using FoxyProxy which is just a nice plug-in to FireFox, it allows you to setup different proxies in FireFox very easily, and you can then hook into Fiddler's proxy quickly, and start to catch requests over the wire when testing local web applications.

Here is how to set up FoxyProxy for Fiddler and FireFox:

1. If you have not already installed Fiddler or Firefox, install these first.

2. Download & install the FoxyProxy plug-in for FireFox.

3. Now you will need to get to the FoxyProxy options.  In FireFox, at the right-hand corner you should see FoxyProxy running:

    foxyproxy_step7

     Here it's just saying that FoxyProxy is not using any proxies at the moment.

     Now right click that bar and choose "Options".

 

4. Now click the "Add New Proxy" button.  We are going to create a new proxy instance in FoxyProxy that simply points to Fiddler's proxy BowserPAC.js config file.

    foxyproxy_step1_web

5. First though we need to create a new pattern for this proxy instance and base it on a localhost wildcard so that any site that you run on localhost will be also caught when this FoxyProxy instance is running later on.

    So click the Patterns Tab then Add New Pattern button, then input the following:

 

    Pattern Name: localhost

    URL Pattern: *localhost*

    and then leave the default "Whitelist" and "Wildcards" options as is

    foxyproxy_step5_web

6. Now click on the Proxy Details tab and select Automatic Proxy Configuration.  Here is where we are going to browse to Fiddler's proxy config file.

    a) In Windows XP, Browse and select the fiddler proxy config file located at the path

        file:///c:/documents and settings/YOURNAMEHERE/my documents/Fiddler2/scripts/browserpac.js

    b) Enable only the Notification about proxy auto-configuration file loads

    foxyproxy_step3_web

7. Next, click on the General tab and fill in the following to define a name for this Proxy instance:

    Proxy Name: Fiddler

    Enabled: checked

    Animate icons when this proxy is in use (optional): checked

    Include this proxy: checked

    foxyproxy_step2_web

    You've just created a proxy instance for Fiddler inside FoxyProxy.

8. Finally click OK and go back to the "Global Settings" tab then just change the "Statusbar Activation" left-click option to "Cycles through

    modes"

    foxyproxy_step6_web

9. Now we are ready to actually use this proxy instance that we have defined in FoxyProxy.

    So in Firefox, look at the right-hand corner and click once on foxyproxy_step7 .  That's FoxyProxy running in FireFox. 

    Now click on it once.

    Notice it will change from being disabled to the pattern status step8a .

    Now we need to tell FoxyProxy which proxy instance (that we just defined in options) to start using.

    To do this, right-click the patterns box and choose the proxy instance you created.  So select "Use proxy Fiddler for all URLs":

    step8

10. FoxyProxy has now been configured for Fiddler as the proxy, and selected as the instance inside FireFox and it's now running the Fiddler proxy.

      Now we can use fiddler to capture any requests made from FireFox on any website with no problem.

      You should now be seeing results in Fiddler (example shown below) after you click around on your localhost site. 

      Here's how mine looks now that fiddler is capturing any clicks made on my ASP.NET localhost web site :

      step10b_web 

      And now we are all set. As you can see above in my example, now you can inspect a ton of things on any requests captured in Fiddler.


Wednesday, May 26, 2010 3:10:04 PM (GMT Standard Time, UTC+00:00) | Comments [0] | ASP.NET#
As you can tell, this is going to be a nice and easy topic.

Got the go-ahead to deploy Facebook Connect to the site I'm working on, everything certified "Works on Dev" so go to push it to the UAT servers.

This environment is load-balanced and has an F5 firewall sitting in front of it, and proceeded to fall over in spectacular fashion.

The bizarre thing is that FireFox and Chrome are happy, while IE (surprise) throws back the mystic error "Redirect Required" with content of

<meta http-equiv="refresh" content="0; url=[MY URL]>

Hmmm.


Facebook xd_receive and Cross Domain Communication


Facebook Cross Domain comms is based on using IFrames to transport data, see http://msdn.microsoft.com/en-us/library/bb735305.aspx for a full explanation.


On investigation of the Big IP logs, we could see the raw request was flagging a Cross-Domain Scripting attack for the IE request (but not for the FF request). 

My gut-feel is that this could be as a result of an IE security patch which puts a whole lot of extra stuff in the Form variables which then confuses Big IP, but this is a complete and utter guess.

The solution?  Patch a hole in the Firewall.  So not really a solution I'm afraid.

Wednesday, May 26, 2010 2:16:59 PM (GMT Standard Time, UTC+00:00) | Comments [0] | Facebook | Web Design#
Saturday, May 15, 2010
Playing around with AJAX and returning data via JSON, I was always getting the error handler called in my AJAX call, despite getting data back from the server.

I noticed that my server code, which I'd quickly stolen from another blog, returned the JSON like this:

            oBuilder.Append("{");
            oBuilder.AppendFormat("'{0}' : {1}", "Minute", "500");
            oBuilder.Append("}");

so this would return
 { 'minute' : 500 }

All good right?

Wrong.  Jquery 1.4 now will parse valid JSON only, and that means the single quotes inside that JSON packet HAVE to be double quotes.





Saturday, May 15, 2010 10:04:32 AM (GMT Standard Time, UTC+00:00) | Comments [0] | Javascript#
Search
Archive
Links
Categories
Admin Login
Sign In
Blogroll