Does asp.net can capture Url param as Variable like flask? [duplicate] - asp.net

This question already has answers here:
Routing with Multiple Parameters using ASP.NET MVC
(3 answers)
Closed 4 years ago.
for example, flask can get param in url:
".com/<name>/<token>"
get 'name' and 'token' as Variable .
Does asp.net can do this?

You can use attribute routing in ASP.Net Web API and should use the Route attribute
[HttpGet]
[Route("GetSomething/{name}/{token})"]
public MyResponse GetSomething(string name, string token)
{
...
}

Related

Servlet unable to get hash fragment from URL [duplicate]

This question already has answers here:
Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?
(12 answers)
How to get Url Hash (#) from server side
(6 answers)
Closed 1 year ago.
Hi after redirection from OAuth server, I am unable to get the complete URL in my JAVA Servlet.My URL looks like below -
https://host.vp.com/gui/MainPage.gdi#scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK
I tried request.getRequestURL() , request.getRequestURL(), request.getPathInfo(), no luck in getting the part of the URL which starts after #, i.e., scope=openid%20profile&id_token=eyJ0eXAiOiJKV86sada0ajdasJUUEB343KHFKK, Can someone help me here?
Your Query string should start with ? instead of # to be able to read in the Selvlet.

Karate; Multiple urls in a single scenario [duplicate]

This question already has an answer here:
Karate API Testing - Reusing variables in different scenarios in the same feature file
(1 answer)
Closed 2 years ago.
This is a followup from a previous question I asked Using response data from one scenario to another
I am looking to take information from a response in one url, then use it in a second url for another assertion.
Something like this:
Scenario: Search for asset
Given url "https://foo.bar.buzz"
When method get
Then status 200
* def responseItem = $.items[0].id // variable initialized from the response
Given url "https://foo.bar.buzz/" + responseItem + "/metadata"
// making request payload
When method put.....
Right now when I run this, it gets hung up on the second Given statement.
Any thoughts on how to resolve this?
As you probably figured out, the "Karate HTML report" will show you the request/response and headers, as long as you put DEBUG log level in your log4j config, and that will answer your question.

Microsoft.AspNet.Identity, use email as username [duplicate]

This question already has answers here:
Configure Microsoft.AspNet.Identity to allow email address as username
(13 answers)
Closed 9 years ago.
I am using Asp.Net Webforms application. I used Microsoft.AspNet.Identity for authentication. I want use user's email address as username. But it doesn't let.
can you help me please?
Probably the problem is the use of non-alphanumeric characters in username. If so use this
UserManager.UserValidator = new UserValidator<TUser>(UserManager) {
AllowOnlyAlphanumericUserNames = false }

How to get the request url from HttpServletRequest [duplicate]

This question already has answers here:
How to get the URL fragment identifier from HttpServletRequest
(2 answers)
Closed 6 years ago.
Say i make a get request like this:
GET http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery|Class|analytics|lightbox|label|jquery-dom|jquery-cookie?q=hello#frag HTTP/1.0
Host: cotnet.diggstatic.com:6000
My servlet takes request like this:
HttpServletRequest req;
When i debug my server and execute, i get the following:
req.getRequestURL().toString() = "http://cotnet.diggstatic.com:6000/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getRequestURI() = "/js/loader/443/JS_Libraries,jquery%7cClass%7canalytics%7clightbox%7clabel%7cjquery-dom%7cjquery-cookie"
req.getQueryString() = "q=hello"
How does one get the fragment information ?
Also, when i debug the request, i see a uri_ field of type java.net.URI which has the fragment information. This is exactly what i want. How can i get that ?
"The fragment identifier functions differently than the rest of the URI: namely, its processing is exclusively client-side with no participation from the server." Wikipedia about the Frament Identifiert
For further reference see the RFC 2394 Section 4.1

Using Special Symbols in ASP.NET MVC Routes [duplicate]

This question already has answers here:
ASP.NET MVC: Route with optional parameter, but if supplied, must match \d+
(6 answers)
Closed 9 years ago.
I want to use the url such as "/ControllerName/ActionName/Id"
Id - only digits or null.
But when I use regular expression in MapRoute, "\d{1,4}", I see the exception - error404 page, when I'm trying to see /ControllerName/ActionName/" page.
Also, I don't know, how I can catch exception with special symbol - ".
Please, help.Thanx.
Try using ( *|\d{1,4}).

Resources