.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

URITemplate Inconsistency... QueryStrings Parameters Sometimes Null - Sometimes Not...

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :WCF
Hello all,

I've encountered a strange inconsistecy in the way WCF parses URIs?

My contract looks like:

    <OperationContract()> _
    <WebGet(UriTemplate:="{CampaignID}/objects?page={Page}&pagesize={PageSize}")> _
    Sub getObjects(ByVal CampaignID As String, ByVal Page As String, ByVal PageSize As String)

    <OperationContract()> _
    <WebInvoke(Method:="POST", UriTemplate:="{CampaignID}/objects")> _
    Sub addObject(ByVal CampaignID As String)

getObjects cannot be run without parameters - in this case, it'll return "Method Not Allowed".

However - if addObject is removed ... getObjects CAN run without parameters (Null will be passed in for Page/PageSize).

Why is there an inconsistency in the way WCF processes query string parameters - is there a way to fix this inconsistency... i

View Complete Post

More Related Resource Links

All parameters null in Update of SQLDataSource?


Hi All,

I have a FormView which is bound to an SQLDataSource. When a user clicks on a save button the form, I need to write any changes made to the FormView back to the table.

I have a Stored Procedure on my MSSQL 2005 database that should be executed when the user clicks on the save button.

It appears the Update is firing, but when I trap the DbCommand object in the SQLDataSource's 'Updating' event, all of the parameters that should be passed to the Stored Procedure are coming through as NULLs. Consequently, the Stored Procedure isn't updating anything.

In the click event of the save button I'm explicitly firing the SQLDataSource's Update method:


The parameters in the SQLDataSource <UpdateParameters></UpdateParameters> section appear to be correct.

Can anyone give me an idea on what to investigate to figure out why it appears the Update is only picking up NULLs?

Many thanks in adavnce,


Parameters and Null Values ..!


Hi There,

I was develop an application (ASP.Net) Using (VS.Net C# 2010 & SQL Server 2008)

And I was applying (3-tyer Basics) and I'm not using wizard forever in my application.

The problem is :

When I try to passing the parameters to database, some fields I don't type it

But it's show in database (Empty like "Space") in text fields and (01-01-1900) in date fields

 Although it's must be (Null) .

How I can pass parameters with Null Values for the fields that's not typed  ?

Thanks in advanced 

SP with many parameters with NULL


I would like to pass many parameters to Stored Procedure, but any can be NULL that means the user does not want to use that parameter to filter the query.

I USE: WHERE (row1=@Parameter1 OR @Parameter1 IS NULL) ...

In case @Parameter is NOT NULL then left side of the query is executed, in case @Parameter is NULL then right side gives "1" and "OR 1" means @Parameter is ignored.

But in case I have 10 parameters each with NULL value then Stored Procedures must executes 1 OR 1 OR 1 OR 1 OR 1 OR 1 OR 1...... which cause slow.

How could I handle NULL parameters(which means no need to fil

Page Methods querystrings are null



I'm having problems with accessing querystring params in my page method. Everywhere I read it says you can access querystrings just fine, but when I try it just returns null, what's the problem?

same problem I found -  http://stackoverflow.com/questions/1765188/access-to-querystring-session-from-a-static-method


thanks in advance

UriTemplate won't match string parameters with slashes


Hello All,

I have a WCF service that takes string parameters in the UriTemplate which contain slashes. For example, I want to setup a UriTemplate like "/items/{itemId}/elements", where the itemId contains slashes.

I tried to use the wildcard, like  "/items/{*itemId}/elements, but using this template chokes the runtime. I learned from this link that it appears to work only when the wildcard appears in last variable is the segment.

I could remove the offending variable (in this case, itemId) from the Uri and add it to the body of the request, but I woul like to avoid it since it would result URLs not very intuitive.

Any help would be greatly appreciated.

Kind regards





ServiceBase OnStart args is always null. How can I get parameters into my service?


I need to be able to pass start parameters to my service.

When manually editing the service in the services dialog, the start parameters that are there are only good for one run. ???? They clear out after each start.  But when I do it this way, OnStart does get the parameters.

So I've modified my Installer to set the start parameters directly. Now when I view the service properties in the dialog, the path to executable now has the parameters there, ex.  "pathtomyexe" /mode=reports . However, when done this way, OnStart doesn't get the parameters. They are null.

How can I get start parameters into my service for every single time it runs, not just once when manual ?





Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

view state vs request parameters


If  the view state is the data entered into the form fields then they are supposed to be available in the request parameters or request body. Then why would we need view state for?


How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

Users getting logged out because HttpContext.Current is null


We've  been trying to fix this one for a couple years, and I'm just out of ideas, so any help is really appreciated!

We've got a fairly large, complex web application that uses Forms Authentication to authenticate users.  Throughout the application we store and retrieve information about users in the Session object, and in some cases in cookies.  In a couple places we check for the existence of the context, and if it's null we send the user back to the login page to re-establish the session. 

Just a quick run-down of this web app: C#, .NET 3.5, IIS 6, ASP.NET State Service to manage session

As for the session timer, we use our own home-grown timer, which is basically a client-side timer, which is backed up by a check to the SQL database to see when their last activity was.  This seems to work well for us.  It's not perfect, but it allows us to notify the user before the session times out, and allows us to be certain we're not logging a user out before their 60 minutes of inactivity is up.

What's happening is that certain users are being logged out after just a few minutes.  We've eliminated the timer as a cause and believe what's happening is the HttpContext.Current is null, so the user is logged out.  We do not know why the HttpContext.Current is null, and I underst

FormView -- Parameters and asp:Table


I've already solved this problem to my satisfaction, I just want to know WHY it works this way.

I have a FormView control bound to an ObjectDataSource.  Let's say our data source is a hypothetical table with three columns:  id, name, age.  Why is it that when I use the <asp:Table> element inside of the FormView, the parameter values are not set, but when I use the standard <table> tag, it works fine?

This seems like a .NET problem to me.  I expect the <asp:Table> element to work in the same way as <table> because they are, for all intents and purposes, the same thing.  Am I missing something?

linqdatasource parameters question



I'm currently getting to know the linqdatasource control. What would happen if several WHERE parameters are added to the linqdatasource control declaritively in the aspx page but no WHERE clause is defined? 

1. is there any issue with setting up multiple WHERE parameters in the aspx markup for linqdatasource but then deciding which ones actually get used at runtime by setting the actual WHERE clause at run time? Would the unused parameters simply be ignored and cause no issues?

2. when you need to modify WHERE clause or WHERE parameters at runtime do you need to do so in an event handler? such as linqdatasource.selecting?
I see from the above link it is possible, but is that the standard way to handle controlling filtering in code behind for linqdatasource?

2b. if you use an event such as linqdatasource.selecting to add where parameters and/or modify the where clause in code will that also break the builtin sorting and paging support of the linqdatasource with a gridview? 

'element.className' is null or not an object



I just downloaded the project, compiled it and ran it right out of the box and when I put the mouse pointer over or remove the mouse pointer from either MenuItem in the menu demo, I generate this error:

'element.className' is null or not an object

It points to this javascript method:

updateClassName: function(operation, element, name, value) {
        this[operation + 'String'](
                function() {
                    return element.className;
                function(newValue) {
                    element.className = newValue;

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend