Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7602739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:29:19+00:00 2026-05-30T23:29:19+00:00

I’m writing a REST webservice having a method like this: [WebGet( UriTemplate = /Test/{p1}/{p2},

  • 0

I’m writing a REST webservice having a method like this:

[WebGet(
    UriTemplate = "/Test/{p1}/{p2}",
    BodyStyle = WebMessageBodyStyle.Bare,
    ResponseFormat = WebMessageFormat.Xml)]
public string Test(string p1, string p2)
{
    // Do something here
}

So if I call basurl/Test/prova/test my method Test is invoked with p1=”prova” and p2=”test” and everything works fine.
Problem comes when I try to use a param having (for example) % char: even translating it in URL code, when I try to call basurl/Test/prova/te%25st I get a
Errore HTTP 400 – Bad Request.

If I use

[WebGet(
    UriTemplate = "/Test/{p1}?p2={p2}",
    BodyStyle = WebMessageBodyStyle.Bare,
    ResponseFormat = WebMessageFormat.Xml)]
public string Test(string p1, string p2)
{
    // Do something here
}

and call basurl/Test/prova?p2=te%25st it works.
Why? What can I do to let first syntax work?

UPDATE:
Look at my answer with a possible solution.
If someone finds a better one, please post it!!
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:29:20+00:00Added an answer on May 30, 2026 at 11:29 pm

    Googling around I’ve just found this link:
    http://weblogs.asp.net/imranbaloch/archive/2010/04/23/understanding-400-bad-request-exception.aspx
    where they say:

    ASP.NET Restrictions:

    After passing the restrictions enforced by the kernel mode http.sys then the request is handed off to IIS and then to ASP.NET
    engine and then again request has to pass some restriction from
    ASP.NET in order to complete it successfully.

    ASP.NET only allows URL path lengths to 260 characters(only paths, for example http://a/b/c/d, here path is from a to d). This
    means that if you have long paths containing 261 characters then you
    will get the Bad Request exception. This is due to NTFS file-path
    limit.

    Another restriction is that which characters can be used in URL path portion.You can use any characters except some characters
    because they are called invalid characters in path. Here are some of
    these invalid character in the path portion of a URL, <,>,*,%,&,:,\,?.
    For confirming this just right click on your Solution Explorer and Add
    New Folder and name this File to any of the above character, you will
    get the message. Files or folders cannot be empty strings nor they
    contain only ‘.’ or have any of the following characters…..

    For checking the above situation i have created a Web Application and put Default.aspx inside A%A folder (created from
    windows explorer), then navigate to,
    http://localhost:1234/A%25A/Default.aspx, what i get response from
    server is the Bad Request exception. The reason is that %25 is the %
    character which is invalid URL path character in ASP.NET. However you
    can use these characters in query string.

    The reason for these restrictions are due to security, for example with the help of % you can double encode the URL path portion
    and : is used to get some specific resource from server.

    So I’m starting to think that my problem is impossible to solve.
    I’m sure that this problem is not present in some REST webservice written in PHP and hosted with Apache, so I think it’s just a IIS/ASP “security” restriction I can’t find a workaround for…

    UPDATE WITH FINAL SOLUTION:
    I found a solution here: read the article to understand everything.
    You should know that it could be risky, so think well before using it.

    <system.web>
      <httpRuntime requestPathInvalidCharacters="" />
      <pages validateRequest="false" />
    </system.web>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.