.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Two controllers/Paths?

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :ASP.Net
I am wanting to create a path somewhat like this:  /Administration/News and have it forward to a News controller instead of it being the action.How would I go about this?Thanks,

View Complete Post

More Related Resource Links

Making Sense of ASP.NET Paths

ASP.Net includes quite a plethora of properties to retrieve path information about the current request, control and application. There's a ton of information available about paths on the Request object, some of it appearing to overlap and some of it buried several levels down, and it can be confusing to find just the right path that you are looking for.

partial view, 2 controllers



This is my first visit to the forums, I hope someone here can help me


I'm writing a small webapplication for creating repair tickets and adding comments, really basic

now I'm writing this in MVC2

So I have 2 controllers, 1 HomeController that does everything related to the tickets (listing tickets, creating new ones, editing) and 1 controller for the comments

the edit view for the homecontroller contains a partial view for /comment/create

so /home/edit/ticketnumber can edit the title and status of the ticket on the left side of the screen, the right side of the screen contains the partial view for adding comments

this is done like this:

Html.Renderaction("Create", "Comment");

but if I look at the generated html code when running the app, both save buttons go to /home/edit/ticketnumber

so the comment is never saved.


I hope this makes sense and that someone can help me solve this

Controllers AccountController IFormsAuthentication MVC 2 error vs2010


I finally got around to trying vs2010 and MVC 2 ... I'm glad I did not put them on a production computer.

My first compile (I have not had a chance to investigate because I just did this and I am too tired).

All I did was create a MVC 2 solution with MSTEST Unit Testing selected too.

I compiled it and get four unexpected errors (because I have heard ASP.NET MVC 2 "alpha" and vs2010 Beta 2 are supposed to be somewhat robust):

In both HomeController and AccountController:

"The type or namespace name "Controllers" does not exist ins the namespace "mvczzzzz001" occurs twice, once for HomeController.cs and once for AccountController.cs.

AccountControllerTest.cs has two errors:  can not find "AccountController" namespace and can not find "IFormsAuthentication" namespace.

With ASP.NET MVC v1.0 there are errors when one uses xUnit.net (version at time of ASP.NET MVC v1.0 RTM) as the test framework but not errors with MSTEST (I prefer xUnit.net to MSTEST).

I am just so surprised to find such errors in vs2010 + MVC 2 ....

is this happening to anyone else?????????????????

Thank you ~~ regards, Gerry (Lowry)

Wrong root, absolute paths '~' don't work.


Hi guys,

I have some kind of strange problem. I use Visual Studio 2008 Standard Edition, and whenever I use ~ in links (like PostBackUrl = "~/Admin/AddProduct.aspx"),  ~ is translated into "C:\DocumentAndSettings\User\Desktop" instead of my application root. Of course I dont have any project on Desktop. It happens in every project I run , even in project from pendrive which works properly on other computers.

How can i solve this problem ? What and where should i change ? I will be very thankful for any help.


External Assembly for Controllers...


I am just learning MVC, so bear with me.

I would like to have a project that contains all of my Controller logic. I'm not concerned with using Areas, as these are still maintained within the same project. 

Consider this scenario:

I have multiple sites/apps that require the exact same interaction in regards to a particular area, say CRUD ops on a user account. I do not want to create all of the controller logic for one site/app, recreate it again for the next, and make sure that I keep all maintenance to each in sync. I would prefer to keep the controllers in a separate project and reference them from the appropriate site.

I know someone will say that the controller logic is a lot of times specific to the application (as I've read elsewhere), but let's just say that it is guaranteed to be the same. I want to focus on the "how" and not the "why".

So far, I've created a class library project with the appropriate references for accessing System.Web.Mvc. How do I proceed with the routing configuration for this? Is this idea even possible? I read a few older articles that were written when Areas were first being introduced that said to create separate projects for them. Is this idea similar to that?

Thanks for your time and noob tolerance.

Data Structures in Controllers


If I make a list of data in a controller to pass to a view,


List<String> something = new List<String>;

ViewData["something"] = something; 


Will this List stay in memory after the Controller returns the view? Should I do "something.Clear()" before returning the view in order to manage server memory?

Specific Error Handler for Area Controllers



I have an area named CMS on my MVC3 Preview 1 application.

Is it possible to have an error view inside the CMS area to display only errors that occurred on the controllers under the CMS area?

Basically I want the errors inside the area to be handled by a different controller than the errors on the "application root".



How to remove the Controller postfix dependency in naming controllers?

In the  Controllers directory, naming every controller with "Controller" prefix seems plain stupid. Is there a way to remove this dependency?

How to create an activity that allows multiple exit paths similar to FlowSwitch and FlowDecision

There have been several threads around this type of request but none have provided a definitive outcome for my requirements:I am looking to emulate the FlowSwitch or FlowDecision in a custom activity so as to simplify end user workflow authoring in a rehosted environment.Currenty I am limited to linking my custom activity to a FlowSwitch or FlowDecision to allow for simple logic to be visually composed. This creates additional complexity that I am trying to avoid.I understand that these are sealed types and even the abstract FlowNode base class of these types does not have any overridable types by design as WF 4.0 favours composition over inheritance.What options do I have to accomplish my objective?If activity composition is the response to my question then could I kindly request that some samples or links to samples are provided?

Controllers. Services or Repositories.

Hello,I have implemented Generic Repository over EF4 with generic methods like: void Add(T entity); Int64 Count(); IQueryable<T> Fetch(); IEnumerable<T> Find(Func<T, Boolean> predicate); T First(Func<T, Boolean> predicate); void Save(); Instead of using this repository on the controllers what do you think about creating more "concrete" services. For example: - PostService would have methods like: FindById, FindByCreatedDate, etc ...- The method PostService.Update would update a post and define the Updated date always as DateTime.Now,The services would return entities that would be mapped to View Models, using AutoMapper, in the controller. So In the controller I would have:IEnumerable<PostListViewModel>= Mapper.Map<IEnumerable<Post>, IEnumerable<PostListViewModel>>(PostService.GetPostsOnCurrentMonth())These services would be used by the controllers instead of the repositories.I am just reformulating a few things on my project templates for use in MVC3 projects and this is one of them.Does this make sense?Thanks,Miguel

dllimport("mapi32.dll") changes the path context of application (i.e. relative paths start pointing

I have a WPF desktop application. We use mapi32.dll to show a new outlook mail window to allow user to send an email. After user sends email / just closes the new mail window without sending email, relative path starts pointing to C:\Program Files\Microsoft Office\Office12. I have office 2007 installed.  How can I restore this relative path ?   Thanks & Regards, Nadeem Ullah

Understanding the normal flow between multiple controllers (mvc 1.0)

I am building a medium to large application with ASP.NET MVC 1.0 (we'll upgrade to the latest after we meet some schedule commitments). The application contains a number of workflows, with a separate controller for each workflow, and the home controller owning the main page of the application. So, I end up with the home page, on which the user makes selections and then clicks one of a number of action buttons to proceed down a given workflow. For a given workflow, I seem to have the following flow between controllers:homeController (home view) --> action-button --> workflowController --> homeController (completion view)I figure the action-button does a post to the home controller, which the selections the user made are saved to session state in the appropriate model. The workflowController will handle things as the user moves through one or more views specific to the workflow, but then things end on a common completion page.My question(s):1 - Is this a reasonable way to break up responsibilities amoung multiple controllers?2 - How do I actual accomplish the hand-off to the workflow specific controller? I'd really like to avoid a redirect and the attendent round trip to the browser since controller structure is really an internal implementation issue and shouldn't impose a performance penalty on the user.3 - Is it possible to pass a model from the originatin

How to create an activity that allows multiple exit paths similar to FlowSwitch and FlowDecision

Hi, I saw replies about create an multi path activity and it's container and they are guid me alot but i can not setup link between two activities in my container with System.Windows.Shapes.Line . can any one help me . can any one send me a sample code please . thanks

DtsConfiguration - One configuration value to multiple paths?

I have an SSIS solution with two packages in it. One is a job that runs daily, and the other is a historical (which wipes the database and re-imports everything from scratch). Both packages need nearly identical values to run. Originally the data flow task in both packages had the same name - "Data Flow Task", and I could use the one set of configurations in the dtsConfig file. I've since renamed the Data Flow Tasks in both packages to - DFT Daily and DFT Historical respectively. So now I have a problem - do I duplicate all of the configuration entries, or is there a way to get a single configuration entry "deployed" into both packages' data flow tasks? So here is an example of what I had: <Configuration ConfiguredType="Property" Path="\Package\Data Flow Task.Variables[User::ProxyUsername].Properties[Value]" ValueType="String"> <ConfiguredValue>jplenderleith</ConfiguredValue> </Configuration> <Configuration ConfiguredType="Property" Path="\Package\Data Flow Task.Variables[User::RequiresProxy].Properties[Value]" ValueType="Boolean"> <ConfiguredValue>True</ConfiguredValue> </Configuration> Here is what I don't want to do: <Configuration ConfiguredType="Property" Path="\Package\DFT Historical Rates.Variables[User::ProxyUs

Report Builder 3 - how to display paths that exceed a hemisphere in a map layer



Does anyone have any novel workarounds for displaying geospatial path/line data in a report that exceeds a hemisphere in size. I would like to display path data for vehicles that traverse the globe in a geography map, i.e. satellite, plane or ship paths. One idea is to break the line path into smaller segments based on a time box such as an hour/week or perhaps there's a way to present a point map layer in Report Builder as a connected line? 

Any ideas/suggestions welcome.

Thanks in advance


How do I maintain relative paths and a navigation bar with master pages


Trying to integrate Expression Web project with Visual Studio .Net project, EW for design, VS for coding.

Master pages seem to be the approved model for 'consistent design' including nav bar etc., but a master

page in root with navbar containing relative path

eg: news/default.htm

when applied to a child page in

eg: register/login.aspx 

generates a composite path:

result: a href:[siteroot]/register/news/default.htm

vs intended result:

intended: a href:[siteroot]/news/default.htm

Rather defeats the object of master pages, if we can't use them 'down' the site tree, and manually building xml sitenode maps and using or coding providers seems overkill, especially since 'consistent look and feel' (including navigation) is precisely what master pages are already supposed to provide.

~/ application roots don't seem to work either (yet I used them profusely previously in custom controls for precisely this function) with web sites located under a server virtual directory

Bad enough needing ExpressionWeb dwt + master pages for a single site, but can't imagine relying on master pages (at all) until we get this basic functionality resolved. Trying hard to like Expression Web and MasterPages, and to learn to do things 'the proper way', but all th

Change image paths programmatically



I am working on a localization project, some of the localized text are in graphics, some of the example graphics  paths:




My web forms use <asp:image> controls and <img> tags (runat = sever) to point to graphics in /en/images. I need to a function to loop through all image control and point them to different paths based on the locale set at runt time. Which event should I override and how do I write it?

All my web pages inherit from a base page, I don't know if that makes differences.




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend