When create a new ASP.NET MVC project in Visual Studio 2008, there is a Default.aspx page by default. It has one line
<%-- Please do not delete this file.
It is used to ensure that ASP.NET MVC
is activated by IIS when a user makes
a "/" request to the server. --%>
In its Page_Load function, it just redirects to "/" to go thro...
I have an Asp.net Mvc site where I want to give a separate access and user interface to different clients like:
http://company1.mysite.com
http://company2.mysite.com
http://company3.mysite.com
Each client will have a different ui but practically same functionality (or with some features disabled).
I'd like to separate graphics for ea...
I noticed that there is one change about ASP.NET Routing. I cannot understand why such change.
In ASP.NET MVC Preview, the routing setting in Global.ascx is like "[controller]/[action]/[id]". Now, it is changed to be "{controller}/{action}/{id}". Why change [] to {} ? Is there some necessity to do that?
...
Hello there!
I'm looking for some information on Routing in MVC with C#. I'm currently very aware of the basics of routing in MVC, but what i'm looking for is somewhat difficult to find.
Effectively, what I want to find is a way of defining a single route that takes a single parameter.
The common examples I have found online is all b...
As a glutton for unproven sexy techniques I've adopted System.Web.Routing in my Web Forms application to manage navigation and such. Further, I'm hoping to move role-based security from web.config to the route definitions itself so I can say "this route is only available to roles x, y".
So I've got the class that implements IRouteHandl...
I will take the example of the SO site. To go to the list of questions, the url is www.stackoverflow.com/questions. Behind the scene, this goes to a controller (whose name is unknown) and to one of its actions. Let's say that this is controller=home and action=questions.
How to prevent the user to type www.stackoverflow.com/home/questio...
I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme:
"{client}/{controller}/{action}/{id}"
This works fine, with URLs such as /foo/Home/Index.
However, when using the [Authorize]...
ASP.NET MVC routes have names when mapped:
routes.MapRoute(
"Debug", // Route name -- how can I use this later????
"debug/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = string.Empty } );
Is there a way to get the route name, e.g. "Debug" in the above example? I'd like to access it in the controller's...
I'm new to ASP.NET MVC and all tutorials, samples, and the like I seem to find are very basic.
Is it possible (and if yes, a good design) to have routes like so:
.../Organization/10/User/5/Edit
.../Organization/10/User/List
In other words; can the urls mirror your domain model?
...
Hi - i'm looking at some pages, and i've noticed that by default for ID in the routing for controller/action/ID is an integer and not a string.
How can I change it so it is a string?
...
We are in the process of designing a simple service-oriented architecture using WCF as the implementation framework. There are a handful of services that a few applications use. These services are mostly used internally, so a basic authentication and authorization scheme (such as Windows-based) is enough.
We want, however, expose some o...
Hi,
Does anyone know how I could go about doing something like :
Html.ActionLink(c => c.SomeAction(new MessageObject { Id = 1 } ))
This should output a link with the url of "/Controller/SomeAction/1", pointing at an ActionMethod along the lines of:
public Controller : Controller
{
public ActionResult SomeMethod(MessageObject messag...
Ok so I've spent a couple hours trying to resolve this issue and have had no leads so far, keep getting the same 404 error. What happens is the website picks up the Default.aspx page and displays it like it should. But the Home page has a clickable image where it routes to another view page. The image code is like so:
<a href="<%= Url.A...
I'm writing some routes for a REST service. One of my resource's URI looks like this
resources/user/:id
I also want to give access to individual attributes of a user, which would look like this
resources/user/:id/:attribute
But when I try to define that latter route, it doesn't work. Here's my ini where the routes are defined
rout...
I have two routes:
routes.MapRoute(
"FetchVenue",
"venue/fetchlike/{q}",
new { controller = "venue", action = "fetchlike" }
);
routes.MapRoute(
"venue", ...
When doing a Ajax call to an MVC action currently I have my javascript inside the View, not inside its own JS file.
It is then very easy to do this:
var xhr = $.ajax({
url: '<%= Url.Action("DisplayItem","Home") %>/' + el1.siblings("input:hidden").val(),
data: { ajax: "Y" },
cache: false,
success: function(response) ...
I must be dense. After asking several questions on StackOverflow, I am still at a loss when it comes to grasping the new routing engine provided with ASP.NET MVC. I think I've narrowed down the problem to a very simple one, which, if solved, would probably allow me to solve the rest of my routing issues. So here it is:
How would you ...
Here is my scenario. For the example lets say that I need to return a list of cars based on a search criteria. I would like to have a single View to display the results since the output will be the same, but I need several ways of getting there. For instance, I may have a Form with a textbox to search by year. I may have another sepa...
Is there a way to link to another View that displays search results without having to use a querystring? For example, I know that I can do the following:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(string txtOrderNumber)
{
return RedirectToAction("OrderLookup", new { controller = "Report", id = txtOrderNumber }); ...
I'm trying to create a route for the following urls:
www.mysite.com/user/username
www.mysite.com/user/username/pictures
I tried doing that with the following code:
routes.MapRoute(
"UserProfile",
"user/{sn}/{action}",
new { controller = "User", action = "Index", sn = "" }
);
So if an action...