Monday 24 June 2013

Unable to start debugging on the web server. IIS does not list a web site that matches the launched URL.


if you're encountering this error it's because you haven't started Visual Studio in Administrator mode. This will particularly be true for Visual Studio 2012 with Windows 8 users.



so start Visual Studio again in Administrator mode and this cryptic error should go away.

Sunday 23 June 2013

Ajax.BeginForm displaying System.Web.Mvc.Html.MvcForm on View

if you're using Ajax.BeginForm() on your view MVC view don't forget to wrap it with a using statement otherwise it will print System.Web.Mvc.Html.MvcForm which is really annoying.

so just make sure that your statement looks like this:

@using(Ajax.BegindForm(....))
{

}

Monday 17 June 2013

Prioritize your wifi connections in Windows 8

Microsoft still refuses us to gives us a GUI to do something as simple as prioritizing what WiFi connections you want prioritized. However, it's easy enough to do.

1)Open command prompt and type: "netsh wlan show profiles"

2)Type the following filling in the parameters with the information displayed on the previous output:
netsh wlan set profileorder name="name of wifi you want to prioritize" interface="name of the wifi interface which you can find on the previous output" priority=1 

obviously replace 1 by whatever priority you want to give that wifi connection.

Thursday 13 June 2013

Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

This is most likely due to the second stupid decision of whoever is leading the IIS team at Microsoft (see my previous post for the first one).

If you install IIS 8.0, it will not by default install the ASP.Net 4.5 module with it. It won't even prompt you though it looks like you have set up everything as it's tucked under the Application Development Features which is semi checked so you'd just assumed that it picked sensible defaults. not so.

They have dropped aspnet_regiis so what you have to do is:

1)Go to Control Panel -> Programs and Features
2)Find IIS 8.0
3)Click on Turn Windows Features on/off
4)Expand the Internet Information Services
5)Expand the World Wide Web Services
6)Expand the Application Development Features
7)Tick Asp.Net 4.5 (and whatever else you may need for that matter)

screenshot:




The requested page cannot be accessed because the related configuration data for the page is invalid.

This error usually means that your applicationhost.config which is the base config installed by IIS on your windows/system32 dir which provides default configuration for .net web sites is denying override for a particular configuration section that you are using in your web.config on your web site.

This error has suddenly become very widespread because in IIS 8.0 in Windows 8.0 the default override setting for the <handlers> section is Deny which means you can't have it in your web.config. Considering that every web site template generated by Visual Studio has the <handlers> section with a few things in it, I can only fathom the logic behind this decision, other than consider it a blunder.

In any case, easy enough to fix. 

1)navigate to windows\system32\inetsrv\config and open applicationhost.config

2)find the section that you need to use in your web.config (this error usually outputs a helpful message telling which section is erroring) and change the setting from Deny to Allow. 

Monday 10 June 2013

Query for listing all foreign key constraints for a table

Here is an sql query you can use to list all foreign keys for a given table:

SELECT
K_Table = FK.TABLE_NAME,
FK_Column = CU.COLUMN_NAME,
PK_Table = PK.TABLE_NAME,
PK_Column = PT.COLUMN_NAME,
Constraint_Name = C.CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME
INNER JOIN (
SELECT i1.TABLE_NAME, i2.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME
WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY'
) PT ON PT.TABLE_NAME = PK.TABLE_NAME
AND PK.TABLE_NAME='tablename'

Sunday 9 June 2013

"An error occurred while processing your request." using Windows Azure

If you're getting the message "An error occurred while processing your request." and you want to see the error in your Azure deployment you have to make sure of two things:

1)turn custom errors off by adding this under <system.web>:

<customErrors mode="Off"/>

2)if it's an MVC project it most likely set up an error handler filter for you so find the App_Start folder find FilterConfig.cs and comment out the following line like this:

//filters.Add(new HandleErrorAttribute());


Wednesday 5 June 2013

Accessing dynamic types from difference assemblies

When you set up a dynamic type in one assembly, you usually can't access it in another one by default. 
However, there is a way. You just have to declare explicitly on your AssemblyInfo to which assemblies you want to expose your dynamic data to by using the InternalsVisibleTo statement.

so, in your AssemblyInfo.cs (or dot whatever else if you're not into C# which makes you a dirty sinner), declare:

[assembly: InternalsVisibleTo("MyAssembly.WhichShouldSeeMyDynamicData")]

Saturday 1 June 2013

"Error 3027: No mapping specified for the following EntitySet/AssociationSet ..." - Entity Framework headaches

If you are developing model-first with Entities Framework (EF) then you may run into this annoying error at times:

Error 3027: No mapping specified for the following EntitySet/AssociationSet [Entity or Association Name]

This may make no sense when everything looks fine on the EDM, but that's because this error has nothing to do with the EDM usually. What it should say is "regenate your database files".

You see, Entities checks against the SSDL and MSL during build so if you just changed your EDM but doesn't use "Generate Database Model..." then it complains that there's stuff missing in your sql scripts.

so, in short, the solution is:

Don't forget to  "Generate Database Model..." every time after you update your EDM if you are doing model first development!