Connecting to a gallery without typing in page name - c#

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

Related

Customize external URLs in ASP.NET MVC

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();

Loading content from DB to aspx page based on URL

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.

Run specific application from a Web Application

I'm sure you all have seen those links are able to run for example Yahoo Messenger application on client side if it is installed on client machine. I want to know bit more about how should I register my protocol (I don't even know what should I call that) to open my specified application.
Please apologize As I don't know what should I tag this question, I tag it with very public tags.
This might be of help to you? :)
As far as i know it's called magnet links... :)
How do I make the website execute links?
Edit: Changed link to more appropriate...

Rewriting URL based on who is logged in

Im looking for the best way to change the URL to pages based on who is logged on, the limitation is all the pages are PRE generated so the actual html will already be generated and cannot be generated again on a pr user basis.
Posible solutions
A posible solution might be to use javascript to basicly add to the end of all URL ?=MyUserName , but im unsure if this will work with all spiders ( By all i mean the major search engines). This solution feels a bit dirty to me..
There might also be some way of of when the request comes in to then basicly say that response is from Default.aspx=?Username with doing a response.Redirect?
Its also importent to remember i will be changing the cache settings based on this, like saying if your not logged in the page can be cached.
I'm not sure if you must use .html files or another specific extension, but you could always create your own handler and process what you want to do on every request that way. Your handler would determine who is accessing the page and then do a Response.Redirect (or whatever action is necessary).

Better approach for my first asp.net project?

Background info: 2 semesters of C#(WinForms), plenty of HTML/CSS skill, brand new to asp.net.
I'm building a site for a friend who's a photographer. It's just a gallery site, but he'd like to be able to update the galleries himself and he's not tech savvy in the least. So I'm using the following approach to the problem:
Using ASP.NET 4 WebForms:
I'm using System.IO to get the names of the folders which represent the "Galleries" and populating a TreeView control for navigation.
When a "Gallery" is selected, I have code that builds a (HTML)list of the image files and populates an UpdatePanel with this list.
As this is all based on the folders/files, I'm building him an secure admin page to upload files to new or existing galleries(folders). He'll also be able to edit(move/delete) the existing files from there.
I got it all to work, which was a nice little victory, but I'm realizing this approach is not optimal, as none of the unique galleries are findable via search engine or even URL; the SEO value is nill; the browser back/forward buttons are useless...
Can you guys/gals recommend a better way to go about this?
Is there a way to modify what I've already done to optimize the project?
I'll gladly start over to do this right.
Thanks
Couple of suggestions, if you are doing this for fun - and want to learn something, consider using ASP.Net MVC instead. Both will work, but doing it with MVC will give you more up-to-date and marketable skills.
Second, unless you really want to write the whole thing from scratch, consider using a package to do most of what you want and then customize it.
Something like this would work quite well: http://www.galleryserverpro.com/ and is open source, free/cheap and well supported.
SInce you are new to asp.net, you can learn a lot by picking thru the open source code and seeing how other people with more experience have already solved the very same issues.
When a "Gallery" is selected, I have
code that builds a (HTML)list of the
image files and populates an
UpdatePanel with this list.
Well, most of your problem is sitting inside this sentence. get rid of the UpdatePanel. When you are making ajax request, you are not able to allow browser history. so SEO, back/forward nav. buttons are always issue with updatepanel.
http://ajaxhistory.com/

Categories