Friday, November 28, 2014

when consuming web services in .net hosted over IIS, getting error "Request format is unrecognized for URL ....."

Server Error in '/' Application.

Request format is unrecognized for URL unexpectedly ending in '/JsonCityList'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/JsonCityList'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Request format is unrecognized for URL 
unexpectedly ending in '/JsonCityList'.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler
(Type type, HttpContext context, HttpRequest request, 
HttpResponse response)+713315
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler
(HttpContext context, String verb, String url, String filePath) +308
System.Web.Script.Services.ScriptHandlerFactory.GetHandler
(HttpContext context, String requestType, String url, 
String pathTranslated) +89
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication
.IExecutionStep.Execute() +516
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +288



Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408



Fixing this issue need to add the following in web.config file.



<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

Saturday, November 1, 2014

Difference Between Stored Procedure and User Defined Function in SQL Server



User Defined FunctionStored Procedure
 Function must return a value.Stored Procedure may or not return values.
Will allow only Select statements, it will not allow us to use DML statements.Can have select statements as well as DML statements such as insert, update, delete and so on
 It will allow only input parameters, doesn't support output parameters.It can have both input and output parameters.
It will not allow us to use try-catch blocks.For exception handling we can use try catch blocks.
Transactions are not allowed within functions.Can use transactions within Stored Procedures.
We can use only table variables, it will not allow using temporary tables.Can use both table variables as well as temporary table in it.
Stored Procedures can't be called from a function.Stored Procedures can call functions.
 Functions can be called from a select statement.Procedures can't be called from Select/Where/Having and so on statements. Execute/Exec statement can be used to call/execute Stored Procedure.
A UDF can be used in join clause as a result set.Procedures can't be used in Join clause