Friday, November 23, 2012

HTTPWebRequest “DELETE” error status 405 Method not allowed in IIS7/IIS7.5

I created a REST API and used REST Client to test the DELETE call and I had an error "Status Code 405 Method Not Allowed". I tried using the IIS 7 and 7.5 I've tried all solutions that I can found in the forums for 1 day, re-register ASP.NET into IIS. But none of the solutions work in my case. Below is the error details I found:

MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName  StaticFileModule
Notification    128
HttpStatus  405
HttpReason  Method Not Allowed
HttpSubStatus   0
ErrorCode   2147942401
ConfigExceptionInfo    
Notification    EXECUTE_REQUEST_HANDLER
ErrorCode   Incorrect function. (0x80070001)
    MODULE_SET_RESPONSE_ERROR_STATUS
Warning    
ModuleName="StaticFileModule", Notification="EXECUTE_REQUEST_HANDLER", HttpStatus="405", HttpReason="Method Not Allowed", HttpSubStatus="0", ErrorCode="Incorrect function

 There are a couple of options to fix this problem:
1) Uninstall WebDAV from the server entirely. You can do this from the Windows Add/Remove features app. This will require a reboot.

2) The second solution is simple. 
A) Go to the IIS Site and click models. Find the WebDAV module and remove it.
Now you can still use WebDAV on your other sites and not interfere with the DELETE method on this site.


B) You may need to find the correct handler mapping and add the DELETE verb

Wednesday, October 10, 2012

Password Hasher

Simple utility for those who want to hash their password on the basis of PBKDF2 algorithm. Link -> download

Tuesday, September 18, 2012

Missing an assembly reference....

Sometimes, while working in MS.NET you add the reference of the project or the assembly and when you build the solution you still get the following errors:
1. Error    507    Metadata file '..\bin\Debug\YYY.dll' could not be found.
2. Error    74    The type or namespace name 'XXX' does not exist in the namespace 'YYY' (are you missing an assembly reference?).

So just to avoid a lot of scratching your heads, the issue involved here is the mismatch of the target framework property of the dll or project for which the reference has been added:

 Solution: Select the project and Go to property page. On "Application" tab select the "Target Framework" as set in the calling project as shown in screenshot below:

HibernateException – A collection with cascade=”all-delete-orphan” was no longer referenced by the owning entity instance


I believe most of us have encountered this error while working with NHibernate. This error comes due to the way NHibernate works and the way we developers habitual of coding :) Doing retrieval and updation of a parent object in the same transaction confuses NHibernate about what to do with the 2 child collections available in the session for the updated parent object and thus this error is thrown. To explain further, let us take an example:

There is an object DOCUMENT with cascade="all-delete-orphan" settings with child collection of PARAGRAPH with one-to-many relationship between them.

If the parent is detached and is then updated then the following lines of code will work:
public void setParagraph(Set dSet)
{    
    this.paragraphs = dSet;
} 

In case DOCUMENT is not fetched and updated in the same transaction then below code lines works:

public void setParagraph(Set<Paragraph> dSet)
{    
    // this.paragraphs = dSet; //This will override the set that Hibernate is tracking.
    this.paragraphs.Clear();
    this.paragraphs.Add(dSet);

}