Archive for category .net

World of VS: Make it easy to change the default browser in Visual Studio Blog

World of VS: Make it easy to change the default browser in Visual Studio Blog.

No Comments

Running multiple ASP.net membership sites under the same domain

We have a bunch of seperate microsites hosting book extras content all running in sub domains for a publishers website. Each site is secured is independantly secured with .net membership. A colleague of mine (Richard!) noticed after putting up the second site, that logging into one, also gave access to the other.

The fix was simple; Because cookies are domain-wide, the first auth cookie was being set, and then picked up by all the other sites on that domain. The fix, as detailed in the Microsoft Patterns and Practices Forms Authentication doc, is to just specify a distinct cookie name per application.

Use unique name and path attribute values on the
element as follows.

<forms name="YourAppName"
path="/FormsAuth" ... />

No Comments

Dummy Image Generator

’nuff said! http://dummyimage.com/

No Comments

ASP.net File Uploads with NeatUpload

File Uploads are a fickle thing, and have been.. well.. always. ASP.net has it’s own default max file size, IIS is also put under strain while processing large files and trapping excpetions when file’s are too large, or providing progress bars during the process is a fiddly process.

I’ve recently started using NeatUpload which is an HttpModule which takes care of uploads, streaming the data straight to storage on the file system, or sql- taking a load off of IIS and also offering progress bars!

It’s a fairly old project, which has only recently gone up on codeplex- check it out!

,

No Comments

ASP.net update panel’s and jQuery

I had a problem today with buttons in an update panel and jQuery- there are some buttons which get hidden or displayed depending on the user’s OS – mac or pc users basically get shown different instructions- However because these buttons are added by a partial post back of the update panel, the jQuery document.ready had already fired before these buttons existed.

So I experimented adding the code to the form.submit event but in the end found the solution on google; I simply added this;

<script type='text/javascript'>
function pageLoad(sender, args)
{
    // your code here..
    showHideMacLinks();
}
</script>

This handles the pageLoad event raised by my update panel which is fired on the initial load and on the partial post back.  You can filter this to only fire on partial post back by adding  “if(args.get_isPartialLoad())”

Found this over on the .net Funda blog

No Comments

Just Won an MSDN Ultimate Subscription!!

I just won a competition, which in itself is quite amazing as i never win anything- but the prize is an MSDN Ultimate Subscription!!!  Checkout the announcment over on the Less Than Dot Blog!  Many thanks to Denis Gobo & Ted Krueger!

No Comments

FileUpload.PostedFile.Filename includes all the client Path info, but only in IE

This is a known problem documented on the MSDN – I’m sure I’ve been caught by this before so thought i would blog it!

Firefox and IE7.05XX treat the PostedFile.Filename property differently.

In Firefox, calling FileUpload.PostedFile.Filename will return the name of the file, with no path information.

In IE7, calling FileUpload.PostedFile.Filename will return the full path of the file + the filename.

e.g. if the client file is located at c:\My Documents\Test.xls, Firefox will return ‘Test.xls’, and IE7 will return ‘c:\My Documents\Test.xls’

No Comments

MIX2010 Videos

Meant to post this a couple of weeks ago- just incase you havn’t already seen them the videos from various sessions at Mix2010 ; live.visitmix.com/Videos

No Comments

ASP.net aspx pages posting back to the wrong URL when using Server Rewrite

Had a problem today working on a new phase of one of our existing sites (a problem which I’m sure I came up against on another site and fixed a few years ago…) – we just added server rewrite with a whole new URL structure like so;

www.site.com/ group name/ series name/ book.htm

This allows the user to chop off a folder and get back to the relevant listing page- pretty standard stuff now days.  So this introduces a bunch of virtual folders.  All the sites resources were set to use absolute paths and everything was loading in and rendering fine, but the page crashed every time I click the “Add to cart” button– bit of a show stopper.

This was because dot net isn’t aware of the rewrite- so while they hit the site on a url like;

childrens-books/beast-quest/book1.htm

asp.net thought the page was at

book-details.aspx?id=9780123456789&catId=1&seriesId=2

so did a post back to that page, relative to the current folder, giving me;

childrens-books/beast-quest/book-details.aspx?id=9780123456789&catId=1&seriesId=2

trying to reference the physical file (which existed at the root level) from the context of a folder which doesn’t really exist.  The fix is easy (once you find it!) – for this site the main asp.net form tag was in the masterpage so I just added the following to the Page_Load of my master page;

form1.Action = Request.RawUrl;

Thanks to Ruslan Yakushev’s post on IIS.net

No Comments

ASP.net membership log times incorrect in the database

A colleague of mine is developing an access controlled solution which prevents users logging in with the same credentials from mutliple locations, using ASP.net membership.  For this he checks session expiry times against the last activity date in the database to see if the user has left the site allowing the session to expire- but he noticed today the code had stopped working.

The clocks went forward an hour in the UK on Sunday just gone as we go into British Summer Time (BST) instead of GMT which turned out to be the problem.  ASP.net membership logs all times in the database using UTC time, matches GMT- the moment we moved into BST we came an hour out of sync!  So he had to convert the code to change our local GMT time to UTC before running any comparisons.  Sql server actually has a function to return the current UTC date/time;

GETUTCDATE()

No Comments