How to create a URL like "http://paramter1.xyz.com/" - asp.net-mvc-4

How to create a URL where,the base URL contains a parameter. For example "blog.msdn.com". This "blog" is a parameter to the base URL "msdn.com". I want a URL like "blog.msdn.com", where "blog" is a parameter variable. How to create this type of URL pattern in MVC4.

in mvc you can change your url of your site page like your domain /controller/view
you can change character of after character of your domain like your domain/instead of controller name/instead of view name

Related

conditionally make different url from controller name in MVC by appending word to controller name

I have a controller called ExpenseController. So the url becomes www.website.com/Expense/ViewName
How do I make the url be instead "www.website.com/HPQExpense/ViewName" without changing controller and folder name?
I want to append "HPQ" to all the controllers based on certain condition. So if condition is true url will be like "www.website.com/HPQExpense/ViewName" else it will be "www.website.com/QBLExpense/ViewName".
Thanks!

How to make seo url for Yii $_GET method using url manager?

I'm working on a site on local server. I have made a form to search country,state and city. After getting the results I see the URL formatted as URL
I want to make this URL as URL
So here I want to know about URL manager rules so I can make it as I want.
Simply add this rule in your url-manager
"site/searchme/<country>/<state>/<city>" => "site/searchme"
Now, you need to have an action with this signature:
public function actionSearchme($country, $state, $city)
You can access $country, $state, $city from url inside this action. For example if your url be like http://localhost/yii_1/site/searchme/UnitedStates/Washington/NewYork, $country will equal "UnitedStates" and so on.

Yii transform url from param/param/param/ to param/param?param

Suppose I have a url like:
site.com/param1/value1/param2/value2/param3/value3/param4/value4
I need to convert this url when a user writes it in url line to:
site.com/param1/value1/param2/value2?param3=value3&param4=value4
P.S. - the number of parameters is variable.
How can I do it?
You need to change the UrlManager Rules according to the situation.
You need to configure the Url manager to handle the first two params as path url and let the rest

what is '*' in ASP.NET MVC 4 Routes

What does the * in the line:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
mean?
Does it mean "match everything that looks like: {resource}.axd/1/2/3/4/5 or something like that?
The wildcard provides a catch-all route. It allows, as you assume, any number of paramters after the wildcard parameter:
AnyResource.axd/any/number/of/parameters/will/be/valid
It's also useful when creating a CMS and you want process the url yourself rather than using static routing parameters. Example:
"{*slug}"
You could create a lookup table in your database and retrieve the specific page for the provided slug.

MVC4 construct url with controller/parameter/action

have a look to the following URL:
https://manage.windowsazure.com/#MYCOMPANY.onmicrosoft.com#Workspaces/CloudServicesExtension/CloudService/MYSERVICENAME/dashboard
It looks like the url is in the form {controler}/ActionName/{parameter}/ActionName
How can I generate such URL in MVC4/Razor?
Indeed, I want to build url in the form:
http://www.myservice.com/Configuration/{Source or Target}/{DomainName}/{ConfigurationType}
ex:
http://www.myservice.com/Configuration/Source/mydomain.com/ConnexionConfiguration
http://www.myservice.com/Configuration/Source/mydomain.com/AttributesConfiguration
Thanks.
You can either create per action routes, for each action, or include the controller name and action name in the url and then use something like this:
routes.MapRoute("Default","{controller}/{source}/{domain}/{action}")
so a controller called Configuration with an action called Setup and a domain of example.com and source of welcome would be
/Configuration/welcome/example.com/setup