C# - Extending The RouteCollection In Routing?

Nov 17, 2010

I have been developing a pure MVC CMS for fun and have run into an annoying bug/feature of ASP.NET routing.Each dynamic managed page in my CMS is associated with a particular route that is pulled from the database. These are loaded at app start. When a user adds a new page or edits the Url of an existing page I need to be able to edit the RouteTable to insert/edit route accordingly.The problem is that the new route does not need to be simply added to the end of the RouteCollection, instead it may need to be inserted into a particular position. Seems logical enough except that the RouteCollection contains only a standard Insert(int idx, RouteBase route) method inherited from Collection<T> which doesn't contain the route name. The name of the route is important as I use it throughout to generate action links.Looking at reflector I can't see an easy way to extend this collection as the _namedMap dictionary is marked as private. I tried chopping the collection at the point of insert and re-adding each item again, however because there is no method to reverse lookup a route's name from the RouteCollection I cannot re-add them with the name they may have had before. So frustrating!!!Why is the name of the route not a property of the route object?Why if MS is serious about us extending MVC and Routing do they make crucial classes hard to extend?Any suggestions as to the best solution here?Edit :Ok maybe I should have been much much clearer here. I am not looking for a critique of my CMS design. I appreciate the comments but this is not what I am asking.

View 3 Replies


Similar Messages:

MVC :: Getting This Error 'IgnoreRoute' Is Not A Member Of 'System.Web.Routing.RouteCollection'?

Jan 27, 2010

I keep getting this error

'IgnoreRoute' is not a member of 'System.Web.Routing.RouteCollection'.

even though I have included the required namespace

system.web.mvc

system.web.routing

View 7 Replies

MVC :: Get Reference To RouteCollection?

Oct 4, 2010

in an action, how do I get a reference to the RouteCollection object? I am using the QueryString to mantain some state variables and notice when I RedirectToAction the querystring in the redirected to action is null. So I would like to use RouteCollection.GetUrl and HttpContext.Response.Redirect to create a customized version
of RedirectToAction.

View 1 Replies

MVC :: Access RouteCollection In Custom RedirectToRouteResult?

Sep 26, 2010

I'm making a custom RedirectToRouteResult so I can have it return a JavaScriptResult if it's an ajaxrequest. To be able to generate the url I think I need access to the RouteCollection but how do I access it in there? Obviously the original RedirectToRouteResult is able to generate the url but I don't know how it does it.

public class RedirectToRouteResult : System.Web.Mvc.RedirectToRouteResult
{
public RedirectToRouteResult(string route, object routevalues) : base(route, new RouteValueDictionary

[code]...

View 1 Replies

Web Forms :: Web.Routing Doesn't Work On Server On IIS Routing

Jul 20, 2010

I tried everything I could find, but still does not work on IIS routing.

View 2 Replies

Routing With Web Forms - Could Not Load System.Web.Routing

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

Rest WCF Url Routing & Web Forms Routing?

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

Web Forms :: URL Routing And Dynamic Routing?

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

Handle MVC Routing Along With Webform Routing

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

Using Or Extending ESAPI.NET V0.2?

Nov 30, 2010

I've been recently tasked with leading an effort to improve our input (and output) validation with OWASP recommendations and PCI compliance in mind. In the process, I'm trying to assess the value of the ESAPI.NET project which does not appear to have seen any activity since the spring of '09 and as it stands is incomplete.

Does anyone have experience using or extending ESAPI.NET v0.2? Is it a good starting place today for building out an infrastructure to address the targeted vulnerabilities?

FYI: I am looking at MS AntiXSS which, of course, only addresses a portion of ESAPI's scope. We already do a good job with SQL injection though there are improvements we need to make.

View 1 Replies

Extending RoleProvider GetRolesForUser ()

Jun 3, 2010

The GetRolesForUser() method in the RoleProvider takes the user login name and returns the list of roles for that user. But in my application this is not enough, I need a few more pieces of information to be able to get the user's roles. How can I get this extra information into the method? I have it in the Session, but I found out that Session is not available in the RoleProvider.

What I had in mind was putting this extra info in some class that extends MembershipUser, assuming I can get to it inside the RoleProvider. But I don't know how to create the CustomMembershipUser and make it part of the MembershipProvider. Is this even possible? The easy way out would be using cookies, but I'm trying to keep away from it.

View 1 Replies

C# - Extending Textbox To Have A Unique Name?

Aug 23, 2010

Is it possible to Extend Textbox to have a Unique Name ? I have tried using UniqueID poperty,but this is not accessible with Request.Form("UniqueID")

View 2 Replies

Extending A Control - Just Inheritance By Another Name?

Aug 15, 2010

When people talk about extending a control are they just talking about inheritance?

View 1 Replies

Extending A DropDownList Control?

Apr 18, 2010

I have a rather large application that has literally a hundred DDLs with Yes / No ListItems. In an attempt to save myself some time, I created a custom control that extends the standard DDL.It all seems to work fine but I am having some issues when assigning the SelectedValue property in code where the selected value does not seem to have an affect on the control. I wonder if I should be adding my items during Init or PagePreLoad? Should I be calling base.OnInit before or after I add the list items? This mostly works but not 100%. (v3.5)

public class YesNoDropDownList : DropDownList
{
protected override void OnLoad(EventArgs e)

[code]...

View 1 Replies

C# - Extending The Base Class?

Mar 5, 2010

When you create a webpage in ASP.net, the codebase inherits System.Web.UI.Page

Now when I extend the page object to check for SessionExpired for example, I create a new class and inherit from system.web.ui.page, and overwrite some functions.

The problem then is that on each page, I have to replace system.web.ui.page with my custompage class.

Is there a way to extend a class by adding methods or modifying its methods directly (e.g. add the sessionExpired check to System.Web.UI.Page) ?

I'm using .NET 2.0

View 2 Replies

AJAX :: CollapsiblePanelExtender Extending?

Sep 30, 2010

I use two different collapsiblepanelExtenders with similar colapsedControlID which is not a matter here. ince both of them working but with some misbehaviour, for example if the first one is open and I click wherever on it , the second one extends. also by clicking on the second one it collapses.That means that some how an event triggers and makes them collapse or extend.I have a kind of editing panel inside each extandedPanel which are used to update something on the page. the problem is that by clicking on eachtextbox or fileupload, the second panel collapses again. before any other action. So that I can not enter the textboxes. I can do that if I use tab button on keyboard. but that sucks really.

[Code]....

it might be because the second extender is inside the collapsible panel itself. but why it doesn't stay in extended state?

View 1 Replies

MVC :: Extending The RazorViewEngine For Custom ViewEngine?

Dec 9, 2010

I were following the tutorial at this page of how to build my own view engine: [URL] And in hope of just extending the existing RazorViewEngine I made some changes to the code in the tutorial...

[Code]....

The thing is that now when I run my site..I get the following error: CS0246: The type or namespace name 'WebMatrix' could not be found (are you missing a using directive or an assembly reference?) and I just cant find a way to solve this..I have added the references.

View 4 Replies

Security :: Extending Timeout On Website?

May 19, 2010

We have an ASP.NET 2.0 site in which we use ASP.NET login / authentication controls.

Our users currently timeout after approx 20 minutes, forcing them to log back in, and this appears to be causing downstream errors in our application.

I have tried increasing the SessionTimeout value to 120 mins (<sessionState timeout="120" />) in the site's web.config file, and the "<membership userIsOnlineTimeWindow="5000" >" value in the web.config is set to 5000 minutes.

These are the only values / settings I can think of to affect this behaviour.

View 3 Replies

Mvc - Form Post Keeps Extending The Browser Url?

Mar 28, 2011

I am trying out ASP.NET MVC2. I have a controller called SearchController and a view folder called Search containing Search.aspx. In my controller I have:

[code]....

In my view I have:

<form action="Search/Post" method="post">
<label><% Response.Write(Model.Title); %></label>
<input type="Submit" Value="First" Name="submitButton"/>
</form>

It works fine the first time I click the button, and the browser shows a url of [URL]. However, when I click the button a second time the browser url changes to [URL] and I get a 404. What am I doing wrong?

View 4 Replies

Security :: Extending .NET Membership Provider

Feb 23, 2011

am having an argument at work on the asp.net membership provider.One of my colleagues says we should modify the tables and add our own custom columns, and i prefer we create additional tables and add relationships.

View 1 Replies

Security :: Extending The CreateUserWizard With New Fields?

Jun 23, 2010

1) Extend the CreateUserWizard control to insert additional User fields (eg. Gender, Age, Occupation, Address, Phone, etc...).

OR

2) Create a brand new Custom Membership Provider of my own and skip using the inbuilt ASP.NET membership system.

What is the best way to create a new User system with my own tables of User data as described above?

Should i perhaps still use the standard ASP.NET membership system and then extend my own Registration page to add more User data to my own SQL backend table using the Identity value inserted into the aspnet_users table?

View 3 Replies

C# - Extending LinkButton Gives Compilation Error

Mar 12, 2010

I extend LinkButton and i get this error:

Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

View 2 Replies

MVC :: Extending The Datata Annotation RangeAttribute?

Sep 2, 2010

Has anyone extended the Range attribute to be able to have a variable range?I have a similar need but I can't make this work:

public class YearRangeAttribute : RangeAttribute
{
public YearRangeAttribute()
: base(typeof(DateTime), DateTime.Now.AddYears(-100).Year.ToString(), DateTime.Now.AddYears(-14).Year.ToString()) { }
}

There is nothing on the page when it is rendered to the browser and the code above doesn't work.

View 4 Replies

Extending The Life Of A Session Variable?

Apr 2, 2010

A user who is browsing the site in french experiences no problems UNTIL they walk away from the site for 20 minutes. The site then defaults to english.

I am assuming - based on what I have seen with IIS and Application Pools - that the sites session variable is expiring OR the application pool is recycling. I have changed their limits to 600 minutes (which is 10 hours) and on a test server this appears to work perfectly fine.

On the live server, however, it does not work.

I have edited the <sessionState> variable on the web.config file to also timeout after 600 minutes, and this still doesn't help.

Is there something I am missing? Is there a way to programatically force the session state to not expire for 600 minutes? If there is, could someone provide a sample code snippet as I am a newbie to ASP.Net prgramming. I am using VB for my pages.

View 2 Replies

Web Forms :: Extending Membership Provider To Include CVs

Jan 23, 2011

1. How can I extend the create user wizard to include an upload control to allow users to upload their CVs.

2. How can I use/extend the membership provider to save the uploaded CVs into the backend db?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved