I am developing a Travels website in asp.ne. for that I need to display URL Name same as whatever Travels Package selected by user.
What I have to do.
I have to design a separate Form for each Travels Package. or i can do another way.
Please give me your advise how to do this
I'm taking a guess here. Are you after Routing and RouteTables?
You can have multiple routes point to the same aspx file and provide different parameters according to what is specified in the route.
Declare a route like this:
routes.MapPageRoute("","TravelPackage/{action}/{packageName}", "~/TravelPackagePage.aspx");
Then in your TravelPackagePage.aspx.cs:
string packageName = Page.RouteData.Values["packageName"]);
Your URL would look like this:
http://yourwebsite.org/TravelPackage/View/PackageX
Related
I have a client web app that I've been asked to make some updates to. I have a small number of development hours to work within so a redesign of the system is not an option at this time.
The app was written using classic asp with logic to pull certain content dynamically from a custom database and to write back certain user actions to the same custom database. There is an admin area for viewing these logged user actions.
At some point in time portions of the web app were migrated to use Umbraco 4 for the cms. I've been tasked with migrating some additional content, that is still being pulled from the original custom database, into the context of the CMS.
The content in question is structured so that the content node's document type points to a special masterpage. The master page has codebehind logic that checks for a query string parameter and uses that parameter to query the database for content specific to that parameter. In then populates one specific section on the page with that content.
The logic also uses the query string parameter when writing user actions back to the custom database.
I need to maintain the url syntax and behavior of writing user actions back to the custom database but move the displayed content specific to that parameter into the CMS somewhere. Where should I place this content in the CMS and how can I access it from those pages via the query string parameter?
Url Examples:
/site_home/Node1/Node2/Node3/
/site_home/Node1/Node2/Node3/?partner=partner1
/site_home/Node1/Node2/Node3/?partner=partner2
/site_home/Node1/Node2/Node3/Review/
/site_home/Node1/Node2/Node3/Review/?partner=partner1
/site_home/Node1/Node2/Node3/Review/?partner=partner2
/site_home/Node1/Node2/Node3/Checkout/
/site_home/Node1/Node2/Node3/Checkout/?partner=partner1
/site_home/Node1/Node2/Node3/Checkout/?partner=partner2
If you can provide a bit clearer explanation of what you are trying to accomplish, I am sure that I can assist you further. However, the code below and link to the discussion from which I pulled it may help get you on the path. Give me some feedback or edit your question and I will edit my answer to assist.
#{
if(!string.IsNullOrEmpty(Request.QueryString["query"]))
{
int result= 0;
if(Int32.TryParse(HttpContext.Current.Request.QueryString["query"].ToString(), out result))
{
umbraco.MacroEngines.DynamicNode node = new umbraco.MacroEngines.DynamicNode(result);
<h1> #node.Name </h1>
}
else
{
<h2>No query found</h2>
}
}
}
Umbraco Forums - Render Node content from querystring
Actually in my application there are two type of searching facility one is Quack search and another is Advance search
and i use routing the url means when i use Quack search with computer then my url is
1) http://www.example.com:1270/Computer-Company/Computer/1
we have more TABS or BUTTON on screen like Projects,Services,Leads....etc by default selected company TABS/BUTTON you can click on any tabs/button
suppose you search with computer then by default company is searching, then you can click on Project, you can see the result computers project and url is like below
Computer-Projects/Computer/
and pagination is working also fine Because we have only one Searching text like computers
But my problem is in Advance search
THERE ARE THE TWO TYPE OF PROBLEM
=> when i search with multiple criteria like Company Name,Contact Person,Tags,....etc
User may be search with all criteria or single criteria so ADVANCE SEARCH URL IS LIKE
3)http://www.example.com:1270/AdvanceSearch/Company/1
so please let me know how can i pass the all data from view to controller at pagination time.
so please let me know how can i pass the data from view to controller with the use of model
Temporary i am passing hidden data,But in controller side parameters write like
public ActionReslut Company(string companyName,string contactPerson,string country.....)
{
that is not proper way
}
You should use a ViewModel that contains all the fields that you need in the search:
public class SearchParameters{
string companyName {get;set;}
string contactOerson {get;set;}
string country {get;set;}
....
}
Your action:
public ActionReslut Company(SearchParameters searchParameters)
and then using these fields to filter your data.
I am trying to use slugs in an MVC web application but can seem to work out the best way to implement them.
I have found the the recommendation on how to create the URL friendly slug stackoverflow slug post
I still want to be able to query the Db with the ID but don't want this to be in the URL similarly to most stackoverflow URLs, for example
http://website/home/list/outdoor-products
How can a slug be displayed in the URL while still passing and using an ID to be used to query with?
It's doesn't really depends on a technology/framework which you are using, the main thing is you have to have destinctive urls to unambiguously select page content.
If you do have unique titles/slugs for pages, then you may use them as identity for content selection. Otherwise, you need to put some sort of id (it could be int or guid, whatever) into your urls. There isn't anything which will hide your int id behind the slug.
Talking about stakoverflow's urls, you'll find id just before the friendly title. Another option could be put actual id at the end of friendly title (friendly-title-1559063).
I have a main page with a large list of companies, I have a search button and if I want to find a company by state or city I can filter my search.
I decide to filter my search by cities, lets say Chicago, and I get 10 companies as a result of my search.
I click any company in that list and I go to the company details but I realize that is not the one I am looking for, so I want to go back to my 10 companies result list but instead I go back to the main company search interface and I have to re-start my search again.
How to use a session variable or cookies for this case?
Somebody can help me with this?
Another valid option not involving Session or cookies would be using the url for passing search parameters. If your site is public this may also help you with SEO.
You could use a friendly url + rewriting rules or just querystring if you are not using any rewriting.
On the company details page you'd store the referrer url and if the user wants to come back, you do it to that page.
I agree with Claudio, but if you do want to use session I would do something like the following
In page load do something like this
if(!Page.IsPostBack)
{
string filter = Session["SearchQuery"].ToString();
if(filter != null)
{
FilterResults(filter)
}
}
And then in your filter event do something like
Session["Filter"] = txtCityName.txt;
FilterResults(txtCityName.txt);
Web pages have moved to use URLs like:
//weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
i.e. they include the title of the page in the url rather than having some coded id.
I understand that this is useful for SEO, and also for users in finding the correct page where they wish to type in the url.
I would like to follow this approach, but wonder how best to acheive it, and particularly how to deal with duplicates.
Is a database trigger which creates the url based on the title and adds a numeric incremental suffix to any duplicates the best way to go, and if so what would such a trigger look like?
Instead of having an id based on a title they could use id based on both a date and a title (2007/12/03/asp-net-mvc-framework-part-2-url-routing). So if you don't have articles with the same titles in one day (which isn't too severe restriction) duplicates are eliminated.
In Wordpress at least, the "slug" (as they call it) is generated once from the item's title and stored separately in the database. If two "slugs" collide, it appends -1, -2, etc. to the end. I personally prefer if you add an (optional) field to the submission form to allow people to insert their own—it allows people to specify a shorter URL than my-long-article-is-hard-to-type.
You've got to model this concept in your application. URL generation based on title can be automatic, but it can't be invisible. WordPress (and probably other CMS's, too) do a pretty good job of this -- they'll default a URL based on the information you enter, but the "key" part of the URL is visible and editable to the user, and uniqueness is enforced at the appropriate level (globally, per month, per day -- whatever).
Making URL generation completely invisible will lead to confusing errors for the user, I believe.
You could do the same thing that SO does. That is, the slug is only there as GoogleJuice. These two URLs resolve to the same thing:
ASP.Net MVC - route object id == title - how to deal with duplicates?
ASP.Net MVC - route object id == title - how to deal with duplicates?
So, in the example you gave, if the CMS gave each post a unique numeric identifier (which I suppose is quite likely) then you can include it in the URL:
http://weblogs.asp.net/scottgu/archive/2007/12/03/1234/asp-net-mvc-framework-part-2-url-routing
In this example, the symbol 1234 is the post's identifier.