MVC :: Routing With Greater Sub Folder Hierarchy?
Jun 15, 2010
I'm currently working on a project where I need to segregate some of the views within a controller I have a little better.I want to do something like:
{controller}/{action1}/{action2}/{id}
So let's just say
/Clients/Jobs/Edit/e124929
So I guess I'm looking to have "sub-actions" of my actions?It's achievable with via routing. How should I set the route up for this, and how should I create the routine in my controller to handle the "sub-actions"?
View 10 Replies
Similar Messages:
Jan 19, 2010
write a Subroutine that takes a parameter value of a Folder name on the server, then looks for all subdirectories beneath it and puts this hierarchy into a DropDownList?
So far I can't get the sub to work as it stuggles with the path structure and the obvious requirement to call itself.
View 3 Replies
Feb 9, 2011
I am trying to implement Url routing in asp.net 4.0. I just a created a small test application. I am trying to browse the pages kept inside the folder. It works fine when i am running in Visual studio..but when i hosted the application in IIS7 then it showed an error.
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
The code i used is. (i am using master page too.)
protected void Application_Start(object sender, EventArgs e)
{
CustomRouteTable(RouteTable.Routes);
}
void CustomRouteTable(RouteCollection routes)
{
routes.MapPageRoute("Telugu", "Movie/Telugu", "~/Telugu/Telugu.aspx");
}
in my default.aspx page i kept a button and on click of the button i wrote.
protected void btnTelugu_Click(object sender, ImageClickEventArgs e)
{
Response.RedirectToRoute("Telugu");
}
View 1 Replies
Mar 14, 2014
I have a site that I setup and users can create dynamic links and part of the link is their company name. Well just found out that if the name of the company has a dot (. or period) then the routing doesn't like that. After searching see that you can't put a dot in the folder name and wonder now that all these urls are out there is there a good way to handle so the user doesn't get the 404 page? Someone said to add relaxedUrlToFileSystemMapping="true" but did this and still throws to 404.
------------------------------
System info
------------------------------
Microsoft Windows Server 2003 R2
Standard x64 Editions SP2
site using ASP.NET 4.0.30319 framework
Using web forms.
------------------------------
Global.asax
------------------------------
Code:
<%@ Application Language="VB" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Security.Principal" %>
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
RegisterRoutes(RouteTable.Routes)
End Sub
Sub RegisterRoutes(ByVal routes As RouteCollection)
[code]...
This works:
[URL]
This does not work because of . (dot) in folder name:
--I get 'The page cannot
View 1 Replies
Jun 24, 2010
I am using URL routing in asp.net application (not MVC) . I have Admin folder in my aaplication which has admin related aspx pages with seperate web.config. I have seperate login form for admin users which is placed in admin folder itself. My issue is whenever I hit [URL] (which I want to go to login form for admin)- it tries to authenticate and goes to login url mentioned in web.config of root folder.
Note: Admin folder has anonymous access in root config file. Also I have set default document in config of Admin folder. I have added following line in global.asax so that routing doesnt work for files in admin folder;
routes.Add(new
Route("admin/{*resource}",
new
StopRoutingHandler()));
I am really confused what is the issue? What I am missing?
View 6 Replies
Aug 18, 2010
I've got webform routing setup on my asp.net webforms 3.5sp1 project. I would like to have the files for the site in a directory called content including the home page as I would like to run multiple sites using the same system. In MVC there is a blank default page and the home page is in a folder called home. I can't seem to replicate this behaviour using web form routing but would like to. The blank page is always hit first. the route handler is hit second - it recognises that the request is for the home page and sets up the routing page but is not used. the route handler code is simple:
public string VirtualPath { get; private set; }
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
string file = requestContext.RouteData.GetRequiredString("File");
string id = requestContext.RouteData.GetRequiredString("Id");
string queryString = "?menuid=" + id;
VirtualPath = "~/" + file;
HttpContext.Current.RewritePath(
string.Concat(
VirtualPath,
queryString));
var page = BuildManager.CreateInstanceFromVirtualPath
(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
Is there anyway I can do this?
Update
Here is my global.asax route code:
public static void RegisterRoutes(RouteCollection routes)
{
Domain.RepositoryFactory repo = new RepositoryFactory();
foreach (var x in repo.MenuRepository.GetAllEnabledGetMenus())
{
if (string.IsNullOrEmpty(x.Url))
{
//add default
System.Web.Routing.RouteTable.Routes.Add(
new Route("Default.aspx",
new RouteValueDictionary(new { File = x.FileName,
Id = x.Id.ToString() }),
new CoreRouteHandler()));
}
else
{
string url = x.Url;
if(x.Url.StartsWith("/"))
{
url = url.Remove(0, 1);
}
System.Web.Routing.RouteTable.Routes.Add(
new System.Web.Routing.Route(url,
new RouteValueDictionary(new {File = x.FileName,
Id = x.Id.ToString()}),
new CoreRouteHandler()));
}
}
}
View 2 Replies
Jul 20, 2010
I tried everything I could find, but still does not work on IIS routing.
View 2 Replies
Dec 12, 2010
I am using:
ASP.NET 3.5 SP1 with Web Forms Routing thru Global.asax (System.Web.Routing and RegisterRoutes)IIS 7
Everything is working fine in my local machine, but it gives the following error in my hosting environment:
Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I did everything inside my web.config file mentioned in the following link:
[URL]
But I am still getting the above error.
What else am I supposed to do fix the error?
View 1 Replies
Feb 22, 2011
I have a Web application where i have added a reference to a RESTful WCF. I got the WCF url Routing to work in my webapplication by adding Inherits="RestService.Global" to the Web applications Global.asax.
<%@ Application Codebehind="Global.asax.cs" Inherits="RestService.Global" Language="C#" %>
But then i tried to create url Routing for the Web application and it does not work with the Inherits="RestService.Global" in the Global.asax. If i take it away it works fine. Is there a correct way to do this.
View 1 Replies
Jan 31, 2011
I'm trying to create my own CMS and I've gotten a little bit stuck at the stage of URL routing.
I want clean URLs without extensions and I'd like to be able to create and modify them in a web based interface without any messing around with IIS or actual files.
I've seen how to create a static route, but for that I need to go into my Global.asax file and manually add it.I would like to have all of these routes stored in a database so that I can easily modify them later.
Does anyone know how this can be achieved?
Just for extra information, I will be attempting to create a feature so that if a path exists, but is later changed, a 301 redirect is created to the new URL, is this also possible? (My first problem is the main issue, but thought I might ask this as well just in case it makes a difference)
View 2 Replies
Sep 2, 2010
How to handle asp.net mvc routing along with asp.net webform routing. I have merged my mvc app into my existing web application. In my web application i have implement routing as below:
routes.Add("View Product Details", new Route("Product/{City}/{Manufacturer}/{Name}/{ProductID}/{*ProductType}"));
Similarly i have implemented routing in mvc as below
routes.MapRoute("Product Details",
"Product/{City}/{Manufacturer}/{Name}/{ProductID}/{ProductType}",
new
{
controller = "Home",
action = "ProductDetails",
City= UrlParameter.Optional,
Manufacturer= UrlParameter.Optional,
Name= UrlParameter.Optional,
ProductID= UrlParameter.Optional,
ProductType= UrlParameter.Optional
});
How to handle both pages, as one is custom web form while other is asp.net mvc view?
View 1 Replies
Feb 8, 2010
Say I'm currently in the code-behind of a root master page of the web site, and I need to know all the different master pages the page is going through to get to me. How do I do that?
this.Page does in fact give me a reference to the page. But when I get this.Page.Master, it seems to give me a reference to back to me even though I know other master pages are in between.
View 2 Replies
Oct 22, 2010
How can I maintain a 3 level heirarchy by using a gridview?
View 1 Replies
May 10, 2010
tell me the class hierarchy of System.IO namespace?It's not clear in MSDN library.
View 5 Replies
Apr 14, 2010
I have about 200 categories that are nested. I am currently reading the documention on the C5 generics library. I am not sure if the C5 library is overkill or not. I am looking at converting all my custom algorithms to the C5 implemention.
This is what I need. If a certain category is chosen i need to find its parents, siblings, direct children, and all children.
This is the way I have it set up. To find the:
Parents: I start from the current location then loop through the list and find the current parent. When I find the parent I loop through the whole list again to find the next parent and so on.
Siblings: I loop through the whole list and find all the nodes that have the same parent as the choosen node.
direct children: I loop through the whole list and find all nodes that is a parent of the choosen node.
All Children: This one took me a while to figure out. But I used recursion to find all children of the choosen node.
View 1 Replies
Jan 25, 2011
[Code]....
and
[Code]....
Filter for the child controller executes earlier than for the base class... How can i revert that behavior ? Order prop doesn't help...
View 9 Replies
Oct 24, 2010
I have a table in my database which keeps track of a 3 level hierarchy. What is the best way to display and change/modify this hierarchy? Which asp.net control to use and how?
View 1 Replies
Mar 8, 2010
Trying to figure out how to programmatically access the web pages in the application. Just something simple like a list of them would be awesome. I know I can create a list but I was wondering if there was something that could 'look' at the pages and add a new one to the list if you make a new page for the application.
Example with 7 pages:
Error
Default
Login
Content
Users
ContactUs
Admin
I am half awake so I may be a little unclear. Maybe puting it all in a single question will be easier.
How do you autogenerate a list of all webpages in your current application?
View 1 Replies
Jul 1, 2010
how to create Hierarchy Drop Downlist
View 8 Replies
Sep 13, 2010
I am working on an ASP.net Forms Application that keeps track of information about different offices in an organization. The offices are organized into a hierarchy.
Some users of the program will have access to certain information about all offices in the hierarchy. Some users of the program will have access to only a small part of the hierarchy.
When a user browses for information they are authorized to see, I would like to present the user with a prompt to choose which office in the hierarchy they wish to see information from.
I want to accomplish the following:
A) I want the user to be able to easily navigate the hierarchy of the organization to locate a specific office.
B) I want the user to be able to navigate the hierarchy without refreshing the page.
C) I want my interface to be able to handle a hierarchy at least four layers deep with less than 100 nodes.
I see that Microsoft includes a TreeView control in the standard collection of ASP web controls.
View 3 Replies
Apr 27, 2010
I have the following sql table which contains menu (website menu) data.
Table Name: MenuItems Columns: Id, MenuId, ParentMenuItemId, Text.
My goal is to bind a DDL according to the following hierarchy (example):
Id: 1, MenuId: 1, ParentMenuItemId: -1, Text: 'One'
Id: 2, MenuId: 1, ParentMenuItemId: 1, Text: 'Two'
Id: 3, MenuId: 1, ParentMenuItemId: 1, Text: 'Three'
Id: 4, MenuId: 1, ParentMenuItemId: 2, Text: 'Four'
Id: 5, MenuId: 1, ParentMenuItemId: 4, Text: 'Five'
Requested result in DDL:
One
-- Two
---- Four
------ Five
-- Three
I think it should contain 'WITH' SQL command.
Note: I'm using C#.
View 1 Replies
Jan 13, 2011
I am using VS 2010 for developing asp.net application. we have a requirment to display 3 level hierarchy data into the server controls, how can I do this implementation. My data look like.
Reporting Divisions (1st Level)
Reporting Groups (2nd Level)
Reporting Units. (3rd Level)
Ex:
Division1 Description (1st Level)
Group1 N/A (2nd Level)
Unit1 Unit1 Description (3rd Level)
Unit2 Unit2 Description (3rd Level)
Unit3 Unit3 Description (3rd Level)
Group2 Description (2nd Level)
Division2 (1nd Level)
Group1 Description (2nd Level)
DivisionN Description
how to implement this? And user need to edit the "description" data from the controls also.
View 2 Replies
Sep 28, 2010
I am looking to create an employee hierarchy in a trace tree and have 2 specific fields in my table ( employee , reports to )
Now a sample data looks like follows
Employee Reports to
User A Manager A
Manager A Senior manager A
User B Senior Manager A
User C Manager A
so on and so forth
Now how do I get a trace tree so that when i click on Senior manager A I get Manager A and User B , and then expand manager A to get user A and User C.
View 4 Replies
Aug 19, 2010
I,m having some issues with 3 user controls.heres the scenario.i have 3 UserControls: ctrA and ctrB and ctrC.the idea is: ctrC is collections of ctrB plus some minor info and ctrB is a collection of ctrA plus soe other minor info.ctrA is a simple control with 2 textbox and a label.u enter values on the textbox and the label shows the values multiplied by each other.ctrA is totally inside a updatePanel and when i drag-and-drop it on a custom-page or to ctrC it works just fine (notice that im breaking the disired hierarchy).but when i add it dinamically to ctrB (the correct hierarchy) its not working.the page is being posted back synchronously and worst,the controls desapear.like if they were never there.
View 3 Replies
Sep 28, 2011
I got a IList<Category> where a Category have an id, name and parentid. Right now I loop over all categories where the parent id is 0 (so they are root) and for each of those child categories I call a recursive function that add the child categories to the child nodes. Works fine. However, I (think) I'm going to do away with the asp:treeview since now, next to each Category I want an Edit and Delete Link.
View 3 Replies