Url.PageLink Helper in razor pages - razor-pages

When I set #Url.PageLink("Project") on a page it generates a link like "http://localhost:5236/Project". But when I set the route parameter in the "Project.cshtml" page like:
#page "{id}", link #Url.PageLink("Project") returns "http://localhost:5236/?page=%2FProject".
I can't understand why. How it works?
How to generate a relative path with a parameter that is set in javascript.
Like:
a.href = '#Url.PageLink("Project")'+'/123';

If you want to add a parameter to url in js,you can try to use Url.Page():
a.href= '#Url.Page("Project")'+'/123';

Related

Why URL module ignores characters after # in node.js

I am using url module, which basically splits a web address into readable part.
var data = url.parse(request.url).pathname
the output of request.url is C:\AppFolder\dropbox\videos\myVideo8#.MP4. After its get parsed, I dont understand why its not returing the value with "#.MP4"
I dont understand why its not returing the value with "#.MP4"
Because #.MP4 is the fragment and not the path component of the URL. (You can read up on URL syntax f.e. on WikiPedia, if you are not sure: https://en.wikipedia.org/wiki/URL#Syntax)
You want to look at hash, not pathname https://nodejs.org/docs/latest/api/url.html#url_url_hash

GET a website url when routing

Sorry, my vocabulary is very limited, any help clarifying this question is deeply appreciated.
I'm building a server using Nodejs and Express, it has a route like /new/:url. I access the value passed on the url by using req.params.url. This works well for simple strings, like chocolate, however, if I pass a website url, like http://www.google.com, then it won't be routed to /new/:url.
Question: how can I pass a website url and access it with Node/Express?
Edit: I am trying to use the GET method, and apparently a way to solve this problem is through Wildcards/Regex.
Thank you very much for helping!
Use Post method.
Set header "Content-Type" : "application/json"
Set body { "urlblahblah~" : "https://www.google.com" }
Then parse It as JSON in server-side
you can use Javascripts encodeURIComponent, so when you passing to your server on client, you will allsways encode the url, so you can pass it as regular parameter. or as mentioned by Hulk if posting is an options you can pass it as body param as well...
var url = encodeURIComponent("http://some.url/asdasa?asdas=12312")
will result in :
"http%3A%2F%2Fsome.url%2Fasdasa%3Fasdas%3D12312"
which is safe for passing as param
The solution that worked for me was Regex. Instead of routing as /new/:url, I used:
/new/:url(*)
So that if http://www.google.com is given as a parameter:
req.params.url = "http://www.google.com"

Python Requests: Use * as wildcard part of URL

Let's say I want to get a zip file (and then extract it) from a specific URL.
I want to be able to use a wildcard character in the URL like this:
https://www.urlgoeshere.domain/+*+-one.zip
instead of this:
https://www.urlgoeshere.domain/two-one.zip
Here's an example of the code I'm using (URL is contrived):
import requests, zipfile, io
year='2016'
monthnum='01'
month='Jan'
zip_file_url='https://www.urlgoeshere.domain/two-one.zip'
r = requests.get(zip_file_url, stream=True)
z = zipfile.ZipFile(io.BytesIO(r.content))
z.extractall()
Thanks in advance!
HTTP does not work that way. You must use the exact URL in order to request a page from the server.
I'm not sure if this helps you, but Flask has a feature that works similarly to what you require. Here's a working example:
#app.route('/categories/<int:category_id>')
def categoryDisplay(category_id):
''' Display a category's items
'''
# Get category and it's items via queries on session
category =session.query(Category).filter_by(id=category_id).one()
items = session.query(Item).filter_by(category_id=category.id)
# Display items using Flask HTML Templates
return render_template('category.html', category=category, items=items,
editItem=editItem, deleteItem=deleteItem, logged_in = check_logged_in())
the route decorator tells the web server to call that method when a url like */categories/(1/2/3/4/232...) is accessed. I'm not sure but I think you could do the same with the name of your zip as a String. See here (project.py) for more details.

How to use hook in WHMCS only on specific page?

If I want to display sidemenu only on affiliates page (affiliates.php) than I'm enclosing code in:
if (App::getCurrentFilename() == 'affiliates'){
}
But how to do same for page index.php?m=somepage ?
You can use the php builtin variables to get the URI, however if you want to use the application object to fetch a specific argument you could do something like:
$whmcs = App::self();
$module = $whmcs->get_req_var('m');

How to rewrite url in codelgniter

Hello First i tell all of you that in codelgniter framework i am new and i have a problem related to my url the url looks like this
http://www.vacationplannersnetwork.com/search/name/france
but i want my URL looks like this
http://www.vacationplannersnetwork.com/france
I do search engine optimization of this website so i want this type of structure ,so if anyone knows then please help me its highly recommended.thanks in advanced.
It can be done over rerouteing.
In your APPPATH . 'routes.php' file add this line:
$route['(:any)'] = 'search/name/$1';
Since you want to have first URI segment matching your results, you would need to add other specific routes before that one. For example:
$route['contact-us'] = 'public_controller/contact_method';
$route['aboout-us'] = 'public_controller/aboutus_method';
/*
* other routes
* here
*/
$route['(:any)'] = 'search/name/$1';
Docs.
Also, don't forget to change links anchor in view files if needed (for static pages/variables).
Just use
$route['france'] = 'search/name/france';
then in <a> should bee
<a href="<?php echo base_url()?>france

Resources