Get URL Params with '#' [duplicate] - c#

This question already has answers here:
Retrieving anchor link in URL for ASP.NET
(3 answers)
Closed 8 years ago.
I have a url that receive request with parameters set like this from the return URL of the GoogleAuth. :
LoginReturn.aspx#state=/profile&access_token=token&token_type=Bearer&expires_in=3600
Because of '#' (instead of '?'), if I look in Request.QueryString or Request.RawUrl, there is no parameter and I need to get this access_token.
What is the correct way to get those parameters ?
Thanks for your help !

Everything that follows # is only for the browser. It's usually used to navigate to an anchor in a page, or for single page applications.
The correct way is to edit your query from # to ?

Related

Regular Expression that matches any .aspx url [duplicate]

This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 7 years ago.
The text I was going through mentioned that following regular Expression matches any .aspx url:
#"?i:^.*\.aspx.*$"
I couldnot understand what ?i:^ did while matching. Pls. explain what part it matches in urls like http://localhost:2447/Out.aspx, https://msdn.microsoft.com/en-us/library/88c54tsw.aspx.
?i means ignore case. Your pattern also has some unneeded fillers. If you only want to check if the string contains .aspx, use this:
(?i)\.aspx
// Match:
http://localhost:2447/Out.aspx
http://localhost:2447/Out.AsPx/suburl
https://msdn.microsoft.com/en-us/library/88c54tsw.aspx

Asp and WebClient: How to get dynamically actual host? [duplicate]

This question already has answers here:
How to get "Host:" header from HttpContext (asp.net)
(4 answers)
Closed 8 years ago.
I want to get datas from an html file on my asp webserver, in Javascript to get actual host we can use the following:
~/mydatas.php
It gives on localhost: "http://localhost/mydatas.php"
I want the same thing but in C# can you help me?
Thanks you.
You could also search in stackoverflow and you will find a lot of answered question which had the same problematic than you. Like this one
Hopes it will help you !
Edit : You can use
HttpContext.Current.Request.Url.AbsoluteUri
It will give you the URL of your web page.
I've already try
HttpContext.Current.Request.Url.Host
which gives on localhost
:\windows\system32\inetsrv\localhost
...

Getting # value at the end of url in asp.net [duplicate]

This question already has answers here:
How to get Url Hash (#) from server side
(6 answers)
Closed 9 years ago.
How to get the value after # in the following url:
www.google.com/trian/test#dummyvalue
I am using ASP.NET and C#
A web browser won't pass this value back to the server. So in a typical scenario with a user on their computer accessing your website. The "fragment" portion of the url won't be supplied to the server. Therefore, your asp.net code can not access it. If you change your code to put this data in the querystring, then you can access it server side from asp.net.

Find out from which url your API called [duplicate]

This question already has an answer here:
Get URL of Referer page in ASP.NET
(1 answer)
Closed 8 years ago.
I'm using web api.My question is: I have to check from where call is coming in Global.asax(Application_AcquireRequestState) because I have to restrict some calls which are coming from unknown urls for the purpose of web api security.
You can use Request.UserHostAddress to get the IP address from which the call is coming and Request.UrlReferrer to get the URL that linked to the current URL.

First character of string to upper ASP.Net [duplicate]

This question already has answers here:
Is there a native Proper Case string function in C#? [duplicate]
(5 answers)
Closed 9 years ago.
I'm attempting to return a username in ASP.net but would prefer to convert the first character to upper, for example if a username is 'test' I would want to return 'Test'.
Code to get username:
<h3>Welcome Home<strong><%: User.Identity.Name %></strong>.
Not 100% sure on how to implement this and I'm pretty sure it will just end up being something simple but any help would be appreciated.
Thanks
FIXED
h3>Welcome Home <strong><%: User.Identity.Name.ToUpper().Substring(0,1) + User.Identity.Name.ToLower().Substring(1) %></strong>.
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(User.Identity.Name);
You can achive that with the following example
string input;
char.ToUpper(input[0]) + input.Substring(1);
char.ToUpper(User.Identity.Name[0]) + User.Identity.Name.Substring(1)
You don't need any code for that, just use plain CSS:
<h3>Welcome Home<strong style="text-transform: capitalize;"><%: User.Identity.Name %></strong></h3>
Working in all browsers as far as I could see.
Live test case.

Categories