MVC :: Why Do Route Values Not Get The New Value

Jul 11, 2010

When I do an Html.RenderAction( action, controller, new { varName = value } ); if the original request had a parameter equal to varName, then the value is not changed in a render action.

Example:

1. Post to "C1/A1" with a string var _test = "abc"

2. Inside C1/A1 get some data and return a partial view

3. Inside the partial view I invoke an action on another controller. The action has an input variable with the same name and type (string _test) Html.RenderAction( "A2","C2", new {_test="fgh"});

4. the value in _test that arrives at C2/A2 is still "abc"

I've traced through it step by step, and the value used in the view render action call is correct, but in the next trace step, the value received at C2/A2 is incorrect.

If this is not an error, and creating a new route value to pass in render action is not the correct way to handle this, what is?

View 7 Replies


Similar Messages:

Accessing Route Values In View Mvc.net

Jul 1, 2010

i m using default route of mvc2 like {controller}/{action}/{id}. i want to access that id field in view. how can i do that without using tempData and ViewData. if i have url like [URL] i need value 14 in aspx view

View 2 Replies

MVC :: Add A Constraint For The Route Values With Periods In?

Sep 17, 2010

If I have a route mapped as follows, how can I add a constraint for the route values with periods in?

[Code]....

View 6 Replies

MVC :: Route With Nullable Values Using UrlParameter.Optional

Feb 23, 2010

I've got a route that I want to be able to pass nullable values to. I was using MVC 1 but updated my solution to MVC 2 to take advantage of UrlParameter.Optional.

My route look like:

[Code]....

Which works fine if I go to http://localhost:1234/Search.aspx/l-1/t-1/p-1/s-1 but when I go tohttp://localhost:1234/Search.aspx/l-/t-/p-1/s- or any combination with missing parameters I keep getting 404's.

Also on a related note since I've upgraded to MVC 2 I can no longer use RedirectToRoute for the above route I get the following error: No route in the route table matches the supplied values. Whereas in MVC 1 it would redirect to it without any problems.

View 2 Replies

Override Route Table Default Values Using Html.ActionLink?

Feb 1, 2011

Global.asax route values
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional, filterDate = DateTime.Now.AddDays(-1), filterLevel = "INFO" } // Parameter defaults
);

Here's my actionlink

@Html.ActionLink(item.MachineName, "Machine", new { id = item.MachineName, filterLevel = "hello" }, null)

When the filterlevel is specified in the actionlink, it generates a url like this: [URL] Which is the same page as I am currently on. If I change the actionlink to use a property other than one that has a default value in the route table (yes, if I use filterDate it messes up too), it generates a link like this:..............

View 4 Replies

MVC :: Removing Automatically Appended Route Values From Html.ActionLink?

Aug 11, 2010

in my mvc2 application i have an action link like

[Code]....

docid is set to empty string because i want to clear ambient value of docid that is present in request context. i have gone through a lot of material on internet and even tried docid=String.Empty but it does not solve the problem and gives me url like /controller/action/id?docid=x. i also write a routeconstraint as suggested but it did not solve the problem either.clear those route values comming from request context with html.actionLink. i don't want to use html.routeLink

View 5 Replies

How To Pass JavaScript Function As A Parameter In The Route Values Of Ajax Actionlink

Apr 20, 2010

I need to pass javascript function as a parameter value to the ajax actionlink in asp.net mvc app. how can we achieve this?

View 1 Replies

MVC - Html.BeginForm(). Can Post Back To A Different Route And Keep Existing Querystring Values

Sep 16, 2010

I have a post-only action that has a different route. In my form, I need to post to it, but also keep the querystring values I currently have.

Initial response: /my/first/path/?val1=hello
Needs to post to: /my/other/path/?val1=hello

It seems when I specify a route, it of course only returns the route and doesn't append the querystring values of my original page (for obvious reasons).Is it possible to cleanly append querystring values to my the action attribute of the form tag?

View 3 Replies

MVC :: Webforms Route / Implementing Route In Global.asax

Mar 13, 2011

I tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax

Currently I use several routes for webfroms. routs template are like below

routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")

I encounter error, when I add below lines to global.asax

routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)

I want to know how could I mix ASp.Net MVC routes with webforms routes.

View 3 Replies

MVC :: A Route Named 'Admin_default' Is Already In The Route Collection?

Mar 9, 2010

when i run the app i got this error

A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name

this is my AdminAreaRegistration

[Code]....

View 2 Replies

Route Constraints And Empty Route?

Sep 24, 2010

I have a url that I want to map routing to:

[URL]

where tabvalue is one of: "personal", "professional", "values" or nothing.

I want to map it to a route like:

Member/Edit/{tab}

But my problem is - I don't know how to specify such constraints. I'm trying this regex:

^[personal|professional|values]{0,1}$

but it only works when I use url

[URL]

[URL]

and doesn't work for

[URL]

how to specify the correct constraint?

P.S. I'm not using MVC, just asp.net WebForms

View 6 Replies

C# - MVC 3 Custom Route Handler - Skip To Next Custom Route Rule?

Mar 14, 2011

Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.

My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?

View 2 Replies

C# - Int Values Get Automatically Converted Into Float Values On Binding The Text Values In Gridview?

Jun 29, 2010

I am getting int values from the stored procedure. But when i bind this datasource with the gridview i am seeing the values being converted into float. i am using Text='<% # Bind("Quantity") %' I wanna that to be displayed as int, with out zero'seg: let the value be 233, when i bind that its getting displayed as 233.00

View 1 Replies

MVC :: How To Add A Certain Route

Apr 5, 2010

I want to do the following:

routes.MapRoute("testwithoutcontroller", "Overview/Index/{year}", new {year = 2010});

But it fails when I call Overview/Index/2010 and gives me this error:

The RouteData must contain an item named 'controller' with a non-empty string value.

What must I do in order to only have Overview/Index be possible for my route?

View 3 Replies

How To Access The Route

Mar 11, 2011

I'm using ASP.Net 4 URL routing on a web forms site.

I have multiple routes to a single page

routes.MapPageRoute("","our-services", "~/Information.aspx");
routes.MapPageRoute("","our-company", "~/Information.aspx");

On the destination page (Information.aspx) how can I tell which route was used to get there, for example was it from our-services or our-company?

View 2 Replies

Where To Use Route-name Of Routing In Mvc

May 19, 2010

i'm new to routing in aspnet mvc.. i have following code:

[code]....

when i enter "localhost/school" in addressbar, it is giving 404 error instead it should route to my "schoolIndex" action

i have given route-name as "School" where it is used ?

View 1 Replies

How To Route Url With # Character

May 3, 2010

How to route url contains # sharp character like this:

~/page.aspx#/Home

to be:

~/Home

View 2 Replies

How To Route URL From One Domain To Another

May 24, 2010

I am an C# ASP.NET developer. I am trying to route URL from one domain to another using Godaddy IIS Virtual dedicated server or Dedicated server for ASP.NET.

For example I have a website application for client_A in my server which is intended to be use by multiple clients with different products.

An example URL: www.myserver.com/client_A/product/bear/?productid=1 or using pretty URL www.myserver.com/A_Application/product/bear/1

I would like to setup for my client to point to client_A using his/her domain.

My Client example URL will be: www.hisserver.com/product/bear/?productid=1 or using pretty URL www.hisserver.com/product/bear/1

View 1 Replies

How To Route Subdomain

Feb 27, 2011

I have made an asp.net mvc 3 application with an area called blog. I want to route this area to my subdomain blog.mywebsite.com. How can I achieve this?

How do I need to define my route? Do I have to configure the DNS?

Currently I just use the default area route. I can access my blog area for now at this way.
mywebsite.com/blog

View 1 Replies

Id In The Beginning Of The Route In MVC?

Feb 21, 2011

I have a situation where I want a route in my application so that the application's index method can recognize this[URL]The problem is that, when I set up the route corresponding to the first URL, the route for the second URL does not work (even if I set up a separate route for that).

View 2 Replies

How Will You Do This In MVC Custom Route

Jan 22, 2010

www.yoursite.com/image/http://images.google.com.ph/images/nav_logo7.png

What I need to know here is the Controller Action, and the Global.asax routes

View 4 Replies

MVC :: How To Add A Custom Route

Feb 15, 2010

I have added a new route to enable me to have nice seo friendly URLs instead of an id field for some news items I am displaying from a database

My global.asax looks like this

[code]...

The problem I have is that since I have added this extra route all my standard URLS (Home etc) are now displaying the controller and action name after them, for example [URL] is being displayed in the URL for my homepage

The news URLS all look fine they are [URL]

why the Controller/Action is now being displayed on non news URL's and how I can stop this happening, would I use a constraint of some sort on the News route ?

View 3 Replies

How To Get Route Name From RouteData

Oct 17, 2010

I have several routes defined in my Global.asax; now, when I'm on a page I need to figure out what is the route name of the current route, because route name drives my site menu. I can't find a way to get current route name.

View 4 Replies

MVC :: Route To An Outside URL From Within A Controller?

Dec 17, 2010

I'm embarrassed to ask this question, but not sure what the syntax is to call a URL from within a controller (not associated with the application).

The reason I need to do this is because I am sharing authentication with another webforms app and would like to clear out the session variables before rerouting to that other URL. I'm just not sure of the syntax to route from an Action method to a URL like www.microsoft.com?

View 2 Replies

C# - Add An Additional Route?

Mar 31, 2010

Here is my default route.

context.MapRoute(
"CreditReview",
"Site/{sitecode}/CreditReview/{controller}/{action}/{id}",
new { action = "Index", id = "" }
);

I'm looking to add 'status'. This is what I currently have and it isn't working. I haven't worked with routes.

context.MapRoute(
"CC",
"Site/{sitecode}/CreditReview/{controller}/{status}/{action}/{id}",
new { action = "Index", id = "" });

View 2 Replies







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