Thursday 8 April 2010

HTML Redirect

I was asked the other day how to perform an HTML redirect and thought I'd share it. I know it's quite a simple thing, but as they say on Who Wants To Be A Millionaire, the question's only easy if you know the answer!




<title>Your Page Title</title>
<meta content="0;url=http://www.domain-name-to-redirect-to.com" http-equiv="REFRESH"></meta>

Your optional text here.


The first line that we're interested in is, <meta content="0;url=http://www.domain-name-to-redirect-to.com" http-equiv="REFRESH"></meta>.  This will redirect the user to the appropriate website after 0 seconds.  You can make the browser redirect as short or as long as you wish.

Finally, in the BODY tag, you can enter optional text which you can display to the user, informing them, perhaps, that you are redirecting them.
The HTML redirect has a further application; I frequently write websites for customers who sign up for hosting packages where the control panel does not allow the MIME types to be altered or added to. So if someone accidentally lands on www.website-name.com, your files will be displayed (.aspx, .aspx.cs...). If you really want them to go to www.website-name.com/Login.aspx, you can write a redirect page. First, find out from the hosting provider the default MIME types and then create a file, using one of the names provided, copy the above code, and you have your own redirect to www.website-name.com/Login.aspx!

Wednesday 7 April 2010

Webservices and data structures

Today I needed to write some webservices to talk to our Microsoft Navision system, but instead of just passing over individual data types, I needed to pass over large amounts of data in one call. To achieve this, I created classes to hold the data to pass back and forth. To achieve this, I created a folder in my webservice, and placed the classes in the folder.
The structure of one of the classes (customer) is show below:
namespace WebService
{
  public class wss_Customer
 {
   public string No_ = string.Empty;
   public string Names = string.Empty;
   public string Name2 = string.Empty;
   public string Address = string.Empty;
   public string Address2 = string.Empty;
   public string City = string.Empty;
   public string Contact = string.Empty;
   public string PhoneNo_ = string.Empty;
   public decimal CreditLimit_LCY = 0.0M;
   public string CurrencyCode = string.Empty;
   public string SalespersonCode = string.Empty;
   public string CustomerDiscGroup = string.Empty;
   public bool PricesIncludingVAT = false;
   public string PostCode = string.Empty;
   public string County = string.Empty;
   public string VATBusPostingGroup = string.Empty;
   public int CreditStatus = 0;
   public int Blocked = 0;
   public bool AllowLineDisc_ = false;
   public string CustomerPriceGroup = string.Empty;
 }
}
Once I had created the classes, I thought I'd return to my console, calling app, update the webservice reference and start filling the class structure, without first writing the web method routines. But I couldn't see the class structures. After much 'faffing' about, I found that I needed to at least write the web method stubs, including the necessary class structure, as show below:
[WebMethod]
    public int PostUnsynchedCustomer_18(wss_Customer custToSynch, string value)
   {
   }
After doing this, compiling the webservice, updating the webservice reference in the console app, I found that I could see the class structure and start populating it with data.

I would love to hear if anyone else has had similar problems or alternative ways of achieving this.

Tuesday 6 April 2010

Altering the error message in a asp:CustomerValidator


I'm currently using an asp:CustomerValidator, and depending on some of the logic within the method that I'm using, I wanted to alter the error message.  So after a little playing around I found that you can access the error message through the sender param that's passed in to your validation method.  So here's the method signature which everyone will be familiar with:

public void ETAValueCheck(object sender, ServerValidateEventArgs args)
So through the sender param you can access the ErrorMessage property as follows:
((CustomValidator)sender).ErrorMessage = "This is a test";
And that's it!  It really is that easy!  Simples! 


ASP.NET Caching

If you want to cache images or anything, in your ASP.NET page, you can either use the following in the markup:

<%@ OutputCache Location="None" %>


or set the Cache property of the HttpResponse in your code-behind class:


Response.Cache.SetCacheability(HttpCacheability.No Cache);

Monday 5 April 2010

CSS Gradient Background

I wanted to create a gradient background to use on one of my web sites today, and thought I'd share this.
Step 1
Create a new graphic file in your favourite graphics package (Firefox, Photoshop etc).  Make the image the following dimensions:
Width: 1px
Height: 1000px
Now choose web safe colours, as this will ensure that the colours are displayed as you want them to.
Finally, using the gradient tool, fill the 1px x 1000px area with your chosen colours.
Step 2
Now choose where you want the background gradient to appear, i.e. the body tag, a container tag etc.
Open your CSS file and type the following:
.body
{
background-image: url(../Images/GradientBackground.jpg);
background-repeat: repeat-x;
}
There you have it, you're background will now have a lovely gradient colour!

Sunday 4 April 2010

SQL Server Row_Number()

I wanted to do some, for me, unusual SELECT statements on data that we had for one of our customers; I wanted to select data between two sequential values, but unfortunately, none of the columns assisted me in anyway (they have a lot of varchar columns).  So I remember that with SQL Server 2005, Microsoft provided some sort of row ID.  So after a bit of digging around (in other words Googling!), I found Microsoft provide the function ROW_NUMBER().  Ha ha, just the ticket!  So after 10 minutes of playing with the new function, here is what I came up with:

WITH AS

(

SELECT ROW_NUMBER() OVER (ORDER BY ASC) AS 'ROWID',
* FROM

)

select * From where ROWID between 0 and 10

The isn't the normal #temp table, because if you do a select from it, the table doesn't exist, only within the WITH clause.
I hope this helps others as it took me time to find the answer and if anyone knows what the WITH clause means, I would be interested to hear.

Saturday 3 April 2010

You are not authorized to view this page

I was at a customer site the other day, attempting to set up IIS web site for my web service (.asmx), but I kept getting the error message, "You are not authorized to view this page".  I couldn't figure out what was causing this and was trying everything from changing the permissions to deleting the web site and starting again, but nothing was working.
After a while I managed to get a different error message saying that the XML for the file, filename.asmx.cs, was incorrect!  What?  Then it dawned on me that I had written the web service against .Net 3.5, and so installed the .Net 3.5 re-distributable.  Great, the XML message disappeared, but the "...not authorized" page was back! Cry
So after a lot of playing around, I found that the following settings made the error message disappear:
1. Go to the Directory Security tab and put a tick in the box, Enable Anonymous Access, and un-tick the remaining four boxes.
2. Go to the web service extensions section and click the Allow button for, All Unknown ISAPI Extensions.
3. And I uninstalled the .Net 3.5 re-distributable and then re-install it.
Brilliant!  The XML message went away and so too did the error message. Cool
However, I then had a different message from my code saying that the user, NETWORK ACCESS, code couldn't access the Microsoft.Net x.x folder.  So I navigated to the said folder, and gave read & write permissions to the user, NETWORK ACCESS.
This finally solved my problem and I was away.  Hope this helps.

Friday 2 April 2010

RaiseBubbleEvent

I've just discovered the cool RaiseBubbleEvent that's provided within ASP.NET.  As the name suggests, it bubbles up event from the called methods, to the calling methods.  So, first, here's the code and afterwards I'll tell you why I needed to make use of it.
private void SomeCalledMethod()
{
/* Do some processing */
...
/* Now raise the bubble event up to the calling method. 
Whoever consumes this bubble event, they will know that it's telling them to Rebind.  Any phrase/word can be placed in here */
CommandEventArgs args = new CommandEventArgs("Rebind", String.Empty);
RaiseBubbleEvent(null, args);
}
protected
override bool OnBubbleEvent(object source, EventArgs args)
{
CommandEventArgs e = (CommandEventArgs)args;
if (e.CommandName == "Rebind")
{
//Rebind code goes here
}
return true;
}
The reason that I'm having to use this code is because I'm creating a web shop for a customer of ours and creating a shopping basket/cart.  The markup for the cart became quite long as I have 40 textboxes allowing the customer to type in part numbers directly, instead of browsing, so I thought I'd create a couple of user controls that could be reused in other projects.  However, when the user clicked on the "place all 40 items in the cart" button, it has to do some validation etc and then if successful, the shopping cart has to be displayed, but the logic to display the cart was in the basket.aspx page, and how was I going to inform this page that the shopping cart needed to be displayed.
So after a few suggestions from my colleagues, I tried using javascript and window.location.reload(), then history.go(0) and finally window.location.href=window.location.href.  Unfortunately the first two went into an endless loop reloading the page, asking did I really want to reload the page and the final one worked, but it just reloaded empty controls.  So I thought, okay, I'll use & set EnableViewState in the root for page, usercontrol and asp controls, but still no luck.  I then came across RaiseBubbleEvent and learnt of it's magical powers!  I wish I had been introduced to it years ago!
Anyway, happy bubbling!

Thursday 1 April 2010

IIS 7 ISAPI Filters

Wow!  I have just spent nearly 4 hours trying to get a new web site up and running on Windows Server 2008, for one of our customers (as explained here in another article, but this time relating to having insufficient IIS permissions), all courtesy of the ISAPI filters and ISAPI extensions not being installed.
I knew where to install them on Vista, but it was Windows Server 2008 that was causing me the problems because they're not enabled in the same place. So, for those who need to know in Vista, follow the instructions immediately below. For those wanting to achieve it on Windows Server 2008, scroll down a little.
Vista
Go to: Control Panel -> Programs and Features -> Turn Windows features on and off (on the left hand side of the screen) and then navigate to what is shown below (you'll need at least ISAPI Extensions and ISAPI Filters ticked): 
Windows Server 2008
Go to: Control Panel -> Programs and Features -> Turn Windows features on and off (on the left hand side of the screen) and then choose the Roles value on the left -> followed by Web Server (IIS). Then on the right hand side, choose the Add Role Services. Then navigate to the Application Development and tick the ASP.NET, ISAPI Extensions & ISAPI Filters. As shown below: 

Wednesday 31 March 2010

Failed to start monitoring changes to Global.asax

I was happily coding away the other day, when I came across the following error message when compiling my code in VS 2008: Failed to start monitoring changes to global.asax.  After a scratch of the head and another attempt at compiling, I still got the same message.  After a bit of digging around, I found the problem was in my web.config file and the offending line was:
After I removed this line, it compiled successfully.  Strange thing was, I have had this line in my web.config file for a long time and only now was the compiler working.  If anyone has any suggestions as to why, I'd be grateful to receive them.

Tuesday 30 March 2010

I have been developing a WCF web service recently and in a previous post, I explain how to specify an EndPoint & binding in code.  That was a few weeks ago and it’s now time to make the web service run on the customer’s production server, however, to put a spanner in the works, not only did the customer want the web service to run over SSL, they created their own certificate, which forced a browser to show the message, “There is a problem with this website’s security certificate”.
I have two web services in this project, a traditional one (asmx) and the WCF.  So the certificate problem caused the asmx web service to fail too, until I found the following piece of code via Google, which I have extended ever so slightly to ensure that the certificate name is as we expected and whether it’s issue date is within bounds (I would attribute it to the author, but far too much water has passed under the bridge and I can’t remember who it was from).  The following code goes in the client (the caller) software:
public class TrustAllCertificatePolicy : System.Net.ICertificatePolicy
{
public TrustAllCertificatePolicy()
{ }
public bool CheckValidationResult(ServicePoint sp, X509Certificate cert,
WebRequest req, int problem)
{
// This is out cert string issuer = ""; DateTime startDate = new DateTime(1753, 01, 01), endDate = new DateTime(1753, 01, 01); try {
startDate =
Convert.ToDateTime(cert.GetEffectiveDateString()); }
catch
{ }
try
{
endDate =
Convert.ToDateTime(cert.GetExpirationDateString()); }
catch
{ }
// Check that the issue and cert start & end date are valid
if (issuer == cert.Subject && startDate <= DateTime.Now && endDate >
DateTime.Now) return true; else
return false;
}
}
You can then issue the following piece of code which will call the CheckValidationRequest:
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(URL); WebServiceClient wService = new WebService.WebServiceClient(new System.ServiceModel.WSHttpBinding(), address); System.Net.ServicePointManager.CertificatePolicy = new WebServiceHelper.TrustAllCertificatePolicy();
Place a breakpoint in the CheckValidationRequest and you’ll see the request being issue.
So, this was perfect for the traditional asmx file, but for the life of me, I couldn’t get this to work for the WCF.  I Googled & Googled and found all sorts of weird & wonderful things that you could try and do to your config file to get the certificate to come through, but in the end, I found the following piece of code & config changes were required to get a self cert to work on a WCF web service:
The following line has been altered from above, to tell the TCP layer what type of transport is required:
WebService.WebServiceClient wService = new WebService.WebServiceClient(new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.Transport), address);
Notice how we need to tell the WSHttpBinding class, the transport mechanism.
Finally, in the web.config file of your WCF web service, you’ll need the following:
behaviors section --> <
bindings> <
wsHttpBinding> <
binding name="TransportSecurity"> <
security mode="Transport"> <
transport clientCredentialType="None"/>

security>
binding>
wsHttpBinding>
bindings>
system.serviceModel>


That’s it!  As I say, it took me hours to get find these tiny number of lines, but I was elated when I had! The errors that I was getting when running my code were: Could not find a base address that matches scheme http for this endpoint with binding WSHttpBinding ,or The requested service could not be activated

Monday 29 March 2010

Error CS0433: type class exists in both dll location and dll location 2

I’ve just had the most annoying few days trying to identify why my Ajax web site worked on my dev & test machines, but it wouldn’t work on the live machine.  I have spent literally hours on this problem and I thought I’d share my solution even though there are other solutions which may help.
First off, I was receiving the following error on the live site when I tried to open any aspx page, even though the Ajax was only in one page:
“Error CS0433: type '' exists in both '' and ''” and I was also getting System.web.extensions.dll problems too.  Google was offering up a lot of results for both problems but they either talked about putting the System.web.extensions.dll in my Bin folder, which I did and made no difference but didn’t sit right with me anyway, or it said that you shouldn’t use an App_Code folder, which I do.
In the end, I opted for creating a new Ajax enabled project and then compare the web.config files, which was successful for me.  Below I’ve listed the two areas in my old web.config file which were wrong and then I’ve listed the new entries which replaced them.
1.  Old section
<configSections>
<sectionGroup name="microsoft.web" type="System.Web.Configuration.MicrosoftWebSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
sectionGroup>
sectionGroup>
sectionGroup>
configSections>
 
New section
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
sectionGroup>
sectionGroup>
sectionGroup>
configSections>
2.  Old section
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Services.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
assemblies>
New section
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
assemblies>
That’s it!  And my code then started to work.  If any of the above helps just one person, I’ll be pleased, because this took an age to figure out.

Sunday 28 March 2010

Content-Type-text-xml-charset-utf-8-was-not-supported-by-service-The-client-and-service-bindings-may-be-mismatched

I'm currently building a WCF web service and as we all know, the URL for the web service is stored in the web.config file, and I knew that when I came to deploy it to the live server, the binding would fail. Yes, I know I could publish the web service to the live server and then Add a reference in VStudio, but I like to put the test and live server URLs in the config file.
Anyway, I attempted to do the following in code, but I kept getting the error message: Content Type text/xml; charset=utf-8 was not supported by service The client and service bindings may be mismatched. And the code that caused the error was as follows:
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress("");
InternalWebService.InternalWebServiceClient wService = new InternalWebService.InternalWebServiceClient(new System.ServiceModel.HttpBinding(), address);
Not exactly the most verbose error message in the world, so I tried a few things but they didn't work, so I started to look at the bindings, as this was perhaps the most likely culprit.  I looked in the web.config file and saw the following section:
<client>
<endpoint address=""
 
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMMDInternalWebService"
 
contract="MMDInternalWebService.IInternalWebService" name="WSHttpBinding_IInternalWebService">
So I scratch my head for a bit and started to think, hang on, wsHttpBinding, I’ve never seen that before.  So I used intellisense and found that if you type System.ServiceMode.wshttpbinding, a new class appears.  After a bit of googling, I found that HttpBinding, is used in Soap 1.1, but Soap 1.2 uses wshttpbinding().  Anyway, I wacked in the code and hey presto, the code started to call my web service.

Saturday 27 March 2010

WinForms & the DataGridView

I was asked to do some WinForm programming the other day, which I haven't done for a couple of years now, because, as most of you are aware, I'm more a ASP.NET man with the occasional Win Mob thrown in.  And boy, was it good to be back!  I forgot how easy it was to do EVERYTHING!  You don't have to worry about CSS, state management, session vars...
Anyway, let me cut to the chase.  I wanted to use the DataGridView, populate it with data, and based on the data coming out of the DB, highlight certain cells, not rows, with the colour red and make the cell editable.  Well, as you know, the DataGridView is editable by default, so I was on a mission.  And the last requirement was to show only certain columns out of the entire data set, so I needed a way of creating the columns.  So, let me get to the point.  Below is how to create the columns:
dataGridView1.Columns.Add("Reason code(s)", "Reason code(s)");
dataGridView1.Columns.Add("Value0", "Value0");
dataGridView1.Columns.Add("Size 1", "Value1");
The first field is the column name, which I believe you can reference with something like: dataGridView1["ColumnName"], but don't quote me, and the second field is the header text for the column.  The final requirement for the columns, was to have a hidden column which would hold the unique key back in the DB.  Here you have to create a new DataGridView column and text box cell and set it properties, like so:

DataGridViewColumn newColl = new DataGridViewColumn();  
newColl.HeaderText = "";
newColl.Name = "NoteID";
newColl.DataPropertyName = "NoteID";
DataGridViewCell oCell = new DataGridViewTextBoxCell();
newColl.CellTemplate = oCell;
newColl.Width = 90;
dataGridView1.Columns.Add(newColl);
GetMobaOutuput();
Finally, I needed to highlight certain cells in red and make the editable and anything outside of the if, not editable.  Here goes:
dataGridView1.CurrentCell = dataGridView1.Rows[count].Cells[0];
dataGridView1.BeginEdit(true);
dataGridView1.Rows[count].Cells[0].ReadOnly = false;
dataGridView1.Rows[count].Cells[0].Style.Font = new Font("Verdana", 10, FontStyle.Bold);
dataGridView1.Rows[count].Cells[0].Style.BackColor = Color.Red;
You seem to need to call the BeginEdit method before you can alter the properties.  It was the ReadOnly property that took me a long time to find.  Setting it to false means that it's editable and vice versa.

Friday 26 March 2010

New line in JScript alert box

I had a jscript alert box being shown in one of my web projects, but I wanted to format the text so that some text appeared on a new line.  I knew the \n would insert a new line character for me, but the code was failing, not even showing the alert box.
I then remembered that you need to escape the escape sequence!  In other words, you have to put in a double slash (\\).  Here's the code:

System.Text.StringBuilder msg = new  System.Text.StringBuilder();
 
msg.Append("<script>");
 
msg.Append("alert(\"You chose date: "
Calendar1.SelectedDate.ToString("d") + ".\\n");
 
msg.Append("The earliest collection date is tomorrow 
(" + Calendar1.SelectedDate.AddDays(1).ToString("d") + ").\\n");
 
msg.Append("Please choose another date\")");
 
msg.Append("</script>");
 
Response.Write(msg.ToString());

Thursday 25 March 2010

Disable typing in a combobox

Just a quickie: I wanted to be able to prevent a user from typing in a Windows Forms ComboBox and struggled to find the answer. Anyway, to stop someone from typing in your combobox, just go to the Properties window, in design mode, and under DropDownStyle, choose the DropDownList. Alternatively, in code, type:
cmbTotalRows.DropDownStyle = ComboBoxStyle.DropDownList;
That's it!

Thanks for your time.

Sys is undefined

Woo!  Just spent a few hours trying to get the Ajax toolkit and the Ajax AutoCompleteExtender working on our companies ISA server.  I placed the AjaxControlToolkit.dll into the Bin folder, but I was constantly getting "Done, with errors" in the IE browser.  Using the Safari browser and the Show Error Console, I found that the WebResource.axd file was not being pulled down, all because the path was not correct.  After many hours, I found that one of the ISA rules was not set correctly.  However, in my many hours of investigations, I found the following two web sites to be particularly helpful:
and

Wednesday 24 March 2010

Failed to start monitoring changes to Global.asax

I was happily coding away the other day, when I came across the following error message when compiling my code in VS 2008: Failed to start monitoring changes to global.asax.  After a scratch of the head and another attempt at compiling, I still got the same message.  After a bit of digging around, I found the problem was in my web.config file and the offending line was:
After I removed this line, it compiled successfully.  Strange thing was, I have had this line in my web.config file for a long time and only now was the compiler working.  If anyone has any suggestions as to why, I'd be grateful to receive them.

Tuesday 23 March 2010

CSS min-height & viewport

I was working on a website the other day which had the usual CSS left, middle and right column, with the middle column being the viewport, or area where the most content was placed.  Anyway, the viewport had too much information on it, causing the content to spill over into the body (yes, I know the viewport is in the body, but I think you get the drift). 
Anyway, I remember setting the viewport before and found the following code in another project of mine, with comments to assist:
#container {
width: 1400px;
margin: 20px auto 0px auto; /* Just your normal margin */
text-align: left; /* Obvious */
background: white; /* Obvious */
border: solid 1px black; /* Obvious */
min-height: 100%; /* Causes the page to be as large as required. */
/* If little content, will be as large as the area INSIDE the browser window */
margin-bottom: -100px; /* Allows an area at the bottom of the screen to */
/* be used for a footer, if required*/
position: relative; /* Obvious */
}
Just to ram home the comment above, that x will allow you to place a footer CSS class in your code, showing such things as copyright info, company info or email info, at the bottom of your website, safe in the knowledge that no matter how much data you have in the viewport, the copyright information will always be at the bottom of the page, just after the content and floating somewhere else.
What are your thoughts on how to set the viewport so that it doesn't look too big?

Error: Cannot write configuration file due to insufficient permissions

I was trying to create a new web site on IIS7 today, for one of our customers, and I wanted to create a new MIME type of .aspx. Every time I clicked the Ok button it kept giving me the following error: Error: Cannot write configuration file due to insufficient permissions.
I first thought that I hadn't given IUSR and IIS_USER access to the folder, but I still received the message. In the end I realised that the file, web.config, was still checked into Team Foundation Server, which meant the read flag was still set on the file.
Once I removed the read flag, I could save the new MIME type!