How can we get Current Page URL in F#, Websharper - f#

How can we get Current Page URL in F#, Websharper.
e.g we do it in c#
string PageUrl = Request.Url.ToString();
It is very simple for expert people i just want to get current page url with querystring complete url
> e.g. http://localhost:58496/default.aspx?id=434

Related

How to properly deal with urls in query string with rails?

I have a base url that i want to redirect the user to, but this url have another url in its query param
for ex:
base_url = "https://www.base.com?origin=#{origin_url}"
the origin url itself have some query params
origin_url = 'https://www.origin.com?utm_source=foo&utm_term=bar'
but there is a problem with that, if I just use this url it comes like this
https://www.base.com?origin=https://www.origin.com?utm_source=foo&utm_term=bar
with that url, the &utm_term becomes a query string for the base url, and not for the origin url
is there a special type of encoding to deal with this nested query string problem ?
I've tired use URI.encode_www_form_component in the origin_url, and I got
https%3A%2F%2Fwww.origin.com%3Futm_source%3Dfoo%26utm_term%3Dbar
so the Full url became
https://www.base.com?origin=https%3A%2F%2Fwww.origin.com%3Futm_source%3Dfoo%26utm_term%3Dbar
but the problem is that I always decode the url before redirect, so it just get decoded again.

Wix Velo - How can I pass in a URL parameter to a wix page, and grab that parm in javascript to use it on the page?

I am seeking to use a Wix page as a landing page. I need to pass in an email address as a URL parameter to the page and have it displayed on the page. How can I pass url parameters into a page - and how can I grab that parm in code? Can someone please point me to, or provide and example of this?
Send your email in a parameter like https://www.example.com?email=example#example.com
Then use Wix Location Query to get the value of the parameter.
import wixLocation from 'wix-location';
$w.onReady(function () {
let query = wixLocation.query['email'];
let email = decodeURIComponent(query); //decode uri encoded values in readable format
console.log(email); //this is your email
});

Coldfusion - Setting/Using URL Parameters

In ColdFusion, I understand how to work with URLs using the query string functions: i.e., the second parameter in:
test.cfm?par1=val1&par2=val2&par3=val3
can be accessed by:
<cfset Param2 = ListGetAt(CGI.QUERY_STRING,2,"&")>
However, I was tasked with making dynamic URLs with the parameters separated simply by slashes, i.e.:
test.cfm/val1/val2/val3
How can I construct a URL this way, and then utilize those parameters in the webpage it links to?
Edit: I understand it would be quite easy to construct a string that is "test.cfm/#val1#/#val2#/#val#" and use it as my URL; I was wondering if there was a cleaner, built-in way for CF to help me do it. I am still lost on how to access those in the page.
Param2 = listChangeDelims(CGI.QUERY_STRING,"/","&");
That will turn "foo=bar&sna=fu" into "foo=bar/sna=fu".
Or listChangeDelims(CGI.QUERY_STRING,"/","&=");
will change it to "foo/bar/sna/fu"

Get Return URL Query String Value having #

I am working on an application that uses Angular.js and ASP.NET MVC. The routes for angular.js contain a '#'. Some pages in the application can be viewed without needing to log in. These pages however contain URL's to pages in the application that need the user to be logged in. They look like:
Want this voucher?
So when these links are clicked, MVC forms authentication redirects to the sign in page with the return URL query string that looks like this:
http://localhost:18030/signin?ReturnUrl=%2f#/shop/voucher/6bc1
So on the sign in pages, when i try to look at the query string I only get '/' for return URL as that is the %2f part. I lose the remaining value because of the #.
If I try to URL encode the link, the # and other '/' characters do get encoded but then the routing gets messed up and I get 404 errors.
Is there anyway to access the full query string value with the '#' in it? I am not sure why forms authentication does not encode the #.
The url fragment is never sent to the server, so you have to get a little creative here.
One way I have solved this in the past is to use client side code to modify the action URL for the login, and append the fragment as a query string parameter.
//Pulls out everything past the '#'
var fragment = $location.path();
$scope.fragmentParam = "&fragment=" + fragment;
You can append that query string param to your form action, and then handle it on the server side in order to redirect the user appropriately.
public ActionResult Login(MyLoginInfo info, string returnUrl, string fragment){
//Normal login code
var redirectUrl = String.Format("{0}#{1}", returnUrl, fragment);
Redirect(redirectUrl);
}
This is a simplified version, but you should be able to get the general idea. You need to pass that information to the server, and then reconstruct a redirect url that includes the fragment.

Parsing a URL Using ASP.NET MVC Routing

I have a URL in string format that I want to parse to get the relevent Route Values. I could parse the string manually, but I want to use my routing configuration so I am not tied to the particular string format (so I can change the URL format easily).
I am trying to use the GetRouteData method on the RouteCollection, but this takes a HttpContextBase parameter. Obviously this works fine when the URL is the current URL, but I need to be able to pass in any URL.
In my routing unit tests I mock HttpContextBase out, but I don't want to do that in production code!
Any ideas?
Probably you find useful info here
http://forums.asp.net/t/1281667.aspx

Resources