I want to build a .NET site with MVC and have some external links on it. These URLs I don't want to show directly, but through customized ones.
For example: instead of https://stackoverflow.com/questions/69996673/lower-case-urls-in-asp-net-mvc, just only http://example.com/link/1234.
I know in PHP man can do it with .htaccess and a php file but I'm not sure it's possible in ASP.NET. Someone has suggested me to do it with .cshtml but I don't know how.
Can someone please help me to clear this question?
Thanks.
Updated:
Thanks for all your tipps. After reading the 2 pages on codeproject.com you suggested, I just think that these are useful only for internal URLs, for external they seem to be complicated.
I would think that for each external one I will have one URL: http://example.com/link/1234 and then when clicked it will link with one View 1234.cshtml. This cshtml file should then redirect to the actual link (I don't know as it's possible with Razor).
So I believe there must be a simpler way to get the job done. So anyone else
has other ideas, please share! Thanks!
In route.config file you can construct your url as the way you want.
You can use HttpResponse.RedirectLocation Property in a controller to achieve this. For detail use this link.
Response.RedirectLocation = string.Format("http://bit.ly/{0}", linkid));
return new View();
Related
I wish to add the ability to like Facebook and LinkedIn paste a URL into a textbox area and it picks up the content and gives a preview aswell as linking to the page/article.
Does anyone know of any existing jQuery etc. that exists and makes this possible for me to implement to a page on my website?
Many thanks in advance.
There are many different ways in doing this. One such way is http://markserbol.github.io/urlive/ which uses JQuery, but there are several for JS, PHP etc.
I'm working on a website where I have users view their gallery by typing in "www.example.com/mygallery" As of now they way I have this working is I create a virtual directory called "mygallery", and upload all the project files to it. This works well enough, but it's kind of clunky. Ideally what I would like to do is have the user type in the url (www.example.com/mygallery), and the website goes to "www.example.com/galllery.aspx?name=mygallery". That way there is no need to create a virtual directory for every user.
I have posted a similar question not too long ago about this, but I specifically said I wanted to use url rewriting to accomplish this goal, and did not get any responses. However I am open to any method of accomplishing this. So any help on this subject is greatly appreciated.
Thank you.
If your site isn't MVC, you can still use the RouteCollection mechanism to handle URL re-writing. Check this - http://msdn.microsoft.com/en-us/library/cc668177.aspx
I'm currently trying to create a small scale CMS for my personal website and thought I'd like to try to make some sort of a page layout from a basic aspx file with some placeholders and load content based on the URL, without the use of url query strings such as ?pageid=1.
I'm trying to wrap my head around how this can be achieved without getting errors of a physical file not existing when I e.g. type in http://mywebsite.com/projects/w8apps/clock.
I've read a lot about BLOB and storing files binarily in the database. But I haven't come across a blog which points in the direction of using a so called page layout and loading content based on the URL instead of a query string.
I'm not asking for a solution, just some hints - blogs mostly - which can point me in the right direction and help me achieve this goal.
To deal with loading a page with a URL that is more friendly, rather than ?page_id=1, you may want to have a look at this article about URL Rewriting and URL Mapping.
http://www.codeproject.com/Articles/18318/URL-Mapping-URL-Rewriting-Search-Engine-Friendly-U
Hope you can find a way of fitting this kind of code into your application!
You questions is too broad but here are couple hints that will point you in the right direction.
Create clear specs before you start working on this. Do you really need to have URLs like this http://mywebsite.com/projects/w8apps/clock ? If yes then check out MVC since it has best support for this
Storing binary files in database doesn’t have much to do with this. You first need to think of how your tables will look like and that is based on what are you trying to achieve…
I’d suggest you install some CRM that if open source and analyze this first. You’ll probably find a lot better ideas this way. Just go to CodePlex and search for CMS.
After reinstallation of VS08 some settings seem to be wrong.
All ASP Projects don't refer to the Homecontroller.
Instead of this, I see the whole directoryindex of the project unless I surf especially to /Home or other controllers.
Does anybody know, whats wrong now?
You need to properly configure your web.config
I think this question will cover you:
Set Default Page in Asp.net
Not sure the title explains what I want to do, so here goes: I have a website constructed with Umbraco 4.5.x and the links in the pages use relative paths. I want to have the domain prepended to these links and don't know how to do that; I didn't really used Umbraco so I am a newby at this :(.
What I want to do is replace links like:
Who we are...
with something like:
Who we are...
or
Who we are...
What are the things that I must do for this? Is it all Umbraco configuration or do I need to write some code? Or both?
I found something about the useDomainPrefixes config but it does not seem to work (not sure if it is even related to what I want to do).
Thank you!
I suggest using UrlAbsolutifierModule ( http://www.paraesthesia.com/archive/2007/12/14/urlabsolutifiermodule---convert-urls-in-asp.net-output-to-absolute.aspx ) or similar.
I finally solved this by using Rewrite rules for IIS, Inbound + Outbound.
I also tried with NiceUrlFullPath but it did not work.