I have looked through SO and the internet in General and I can't seem to understand whether the following is possible
I have a link to an action:
Link to Subject
This works fine, I can use the id, to get the Subject and all other info I need for the model.
In the browser it shows:
http://www.example.com/Main/Subject/1
This is just fine, but it is not pretty or very helpful for the user.
I would like to be able to look up the subject from the Id in the Action and modify the URL to look like:
http://www.example.com/Main/Subject/Science
Is this possible and if so, could someone give me a steer on where to find out how to do it.
I cannot change the parameter to a string because the subject name is not unique, only the id.
well you can use the dBprovider feature in urlrewrite 2.0 forr iis 7 and above. what you have to do is create a table in database that store both urls i.e
'http://www.example.com/Main/Subject/Science'
and
'http://www.example.com/Main/Subject/1'
it will match with the url you want to show 'http://www.example.com/Main/Subject/Science' and redirect to the actual url i.e is to 'http://www.example.com/Main/Subject/1' for more info check this
http://www.iis.net/learn/extensions/url-rewrite-module/using-custom-rewrite-providers-with-url-rewrite-module
Related
I'm trying to migrate my ASPX site to Kentico, and as part of my task I'm migrating URLs. I need to preserve my URL structure, so I need to keep URLs which look like : "foo.com/bar.aspx?pageid=1".
I checked page's "URLs" property tried to use wildcards, some patterns like /bar/{pageid}- /bar/{?pageid?}-, etc but Kentico always replaces question marks.
Is there a way to achieve that via the admin interface?
You don't need to do anything in order to use "foo.com/bar.aspx?pageid=1" url.
Create a page under the root and call it bar, so you'll get a page # foo.com/bar.aspx. Kentico and/or .net does not care what you add to a url after question mark, so foo.com/bar.aspx?pageid=1 will work as well as foo.com/bar.aspx?someparam=sdf, or foo.com/bar.aspx?id=1&p=3&t=3.
You may (or may not) implement some functionality based on query string (e.g. paging), so it will parse query string and act in appropriate way.
By default Kentico UI does not handle adding URL aliases with URL parameters like you show. There is an article on the DevNet for a URL Redirection module which has code you can import into your site to allow you to perform these redirects within the Kentico UI. I'd suggest using this approach.
Unfortunately, I can't share a code sample since it's an article but it also has a link to download the code too. This appears to only be coded for Kentico 8.2 right now but I'm guessing you could do some work to make it work for other versions if you needed.
I think there are few concepts that you are clubbing here. I will start with your line code here
/bar/{pageid} - {pageid} is a positional parameter in Kentico's language if you choose to use dynamic URLS based on patterns. SO if you have a code that relies on pageid parameter to fetch some data then Kentico will pass that value. E.g in case of /bar/420, it will pass pageid as 420 different web parts on your template
/bar/{?pageid?} - This will search for query string parameter "pageid" on the request URL and replace its value here. So if you passed foo.com/bar.aspx?pageid=366, the resulting URL will be /bar/366
The #1 is positional parameter and #2 is the way in which Kentico resolves query string macros.
I hope this clarifies.
My task is the following, I need a way to store a query string value of s and pass it to the merchants Order Confirmation email.
consider the following,...mybigcommerce.com?s=fb.
Let's say that my client posts his website link to facebook and adds in a query string of s with a value of FB (facebook).
The desired result would be that on the initial load of the page, the query string would be saved as a cookie(or in Bigcommerce's case a global or store front variable)
Once I have it saved, I now know that you just simply append the variable to the email template.
example output:
email template source : %name_of_variable%.
My problem is, however, I don't see how to store the value into a variable.
Can I accomplish this without using the API, or for that matter can I do this using the API?
Thank you in advanced, I hope I have provided enough information.
Unfortunately, you cannot create your own variable in the email templates. The variables used here have been created and are supported by code within the core application. As such, it would require a core application change to extend existing functionality/add a variable. There isn't a way for you to write to an existing variable either.
I am writing an asp.net web application for internal automation.So, I am not thinking about SEO or user-friendly URLs. Just I want to change URLs for hide path and file name and query string. For example I want this URL "http://test.com/Admin/Create.aspx?id=345&name=pin" be shown for user something else that is not understandable like an encrypted URL "http://test.com/enc=nidfvegvbervmxvpazxczxcwefve" or show all URLs in all formats in a same way like "http://test.com/".
I read some articles about URL rewriting and URL routing. However, I think their method work reversely. I mean when user write "http://test.com/products/book", these method could assume it as "http://test.com/products.aspx?type=book" but I want that user couldn't see real URL ever.
Any idea?
I think what you might be looking for is Server.Transfer - check out:
http://msdn.microsoft.com/en-us/library/540y83hx.aspx
Just Encrypt the query string and decrypt on calling it
Something like
http://www.aspsnippets.com/Articles/Encrypt-and-Decrypt-QueryString-Parameter-Values-in-ASPNet-using-C-and-VBNet.aspx
Ok, I've been bugging with this for too long.
I need to call my website from a rough VB.net app. Then only thing I need is to attach a query string parameter to the calling url, so I can distinguish the pages to be shown to different VB app users.
So I want to click a button and launch that website, giving this parameter.
First I was bugging with adding the system.web libraries. Now I can't use Request/Response.QueryString as well.
I tried getting some example help from this post. but as I said before - I cannot make use of Request.QueryString as I cannot import it.
I am stuck here:
Process.Start("http://localhost:56093/WebSite1?id=")
I need to attach a query string parameter to the url and then open the website with that url.
Can someone just give me a sample code for my problem.
Query parameters are parsed by the web server/http handler off the URL you use to call the page. They consist of key and value pairs that come at the end of the URL. Your code is nearly there. Say you needed to pass through the parameters:
ID = 1234
Page = 2
Display = Portrait
Then you'd turn them into a URL like this:
http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait
Therefore in your code you'd have:
Process.Start("http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait");
I am facing some problem or maybe I am confused. I've followed the following link to generate dynamic Site Map:
MVCSiteMapProvider Dynamic Sitemap
I am confused at node.RouteValues.Add("id", album.AlbumId); in the class given in above link. My website links are not in the form given in the example they discussed (their URLs are like mysite.com/controller?id=some id)
where as my URLs are in following format:
mysite.com/mycontroller/querystring1/querystring2/querystring3
How can I "mention" such kind of URL in node.RouteValues.Add(..., ...); so that it should redirect to mysite.com/controller/querystring1/querystring2/querystring3?
Thanks
The format of the URLs makes no difference. Either way, they are transformed into a collection of route values, which is what MvcSiteMapProvider uses under the hood.
Therefore, the same line node.RouteValues.Add("id", album.AlbumId); can be used in either scenario to make the node match. The actual processing of the URL into route values is done by .NET routing, not MvcSiteMapProvider.