MVC :: Route - Add Dynamic Prefix To Url

Feb 3, 2011

I want to add a dynamic prefix to the url for some of the Views in my site, e.g. [URL] but am having difficulty. Out of the box I have [URL] but need to set a prefix dynamically. I created another Route in the Global.asax like so, but is is even needed? If it is how do I call it from my controller?

routes.MapRoute(
"Questions", // Route name
"{dyna}/{controller}/{action}/{id}", // URL with parameters
new {dyna = "dyna", controller = "Quote", action = "Questions", id = UrlParameter.Optional } // Parameter defaults
);

View 12 Replies


Similar Messages:

MVC Action Parameters With Binded Prefix Not Compatible With Url.Route In Global.asax?

Nov 17, 2010

I have a details page containing a form field named UserId. On the same page i have another search form with a field also named UserId.

I am using Html.LabelFor(vm > vm.UserId) and Html.TextBoxFor(sm > sm.UserId) on the two different view models, vm being the view model and sm being the search model. (Yes, the UserId property on the two models has identical names - because they are the same domain property.

When i navigate to the page, the populated UserId on the vm is inserted into BOTH form fields named UserId by MVC. Even the sm.UserId are empty.

That is my initial problem. There are a few ways ti avoid that. My solution was to use the Prefix flag for the sm.

[code]...

My problem is that MVC can't map the Search.UserId (because of the .) to fit the UserId (prefixed with Search) in the action shown above.

So it seems like MVC has a prefix-feature, that are actually nok fully supported through the Route-handler.

Ofcourse i could rename the Search.UserId to Search_UserId, but then the name dosent match the name MVC expects in the recieving action above. (expects Search.UserId) Renaming The UserId property of the search model would fix the issue, but since it is the same value in the domain, this seems like a workaround.

View 1 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

C# - How To Route "pretty" Dynamic URL (without Query String)

Dec 20, 2010

Well, i know the title isn't very specific, but i couldn't find a better succint description of what i'm looking for.i want to have a default.aspx so that when a user types:

http://www.mydomain.com/randomstring

i can use the randomstring to query a table on page load. More specific:

. I will be importing batches of users to my database through a csv file.

. in that process, a random string will be generated

. i will send that url to each user by email

. when the user clicks through that link, i want my aspx(c#) to interpret that string, query a table that gives me a second url, this one with querystring, and Redirects the user to that second address

View 1 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

XMLNode Add Attribute Without Prefix

Jan 26, 2011

I have the following method:

Code:

XmlNode AttributeNode = xmlDocument.CreateNode(XmlNodeType.Attribute, fieldName, WILTSNAMESPACE);
AttributeNode.Value = fieldValue;
parentNode.Attributes.SetNamedItem(AttributeNode);
this create (for example):
<Person d2p1:PersonRole="Boss">

How do I add an attribute without the d2p1: prefix:

<Person PersonRole="Boss">

View 5 Replies

SQL Server :: Adding Prefix With Primary Key?

Mar 31, 2011

I've a scenerio where i've to create a primary key with prefix Rad####. For example Rad0001. How to do that.

View 2 Replies

Web Forms :: Multiple Controls Under One Tag Prefix?

Nov 17, 2010

I have a C# application with a folder Controls (has three ascx files in it) in the same namespace. This is a sort of toolkit of reusable controls relating to this application. I currently have to register three different tag prefixes to use the controls but this seems messy. How can I reference all controls with a prefix such as mytoolkit:* where * is the name of the control I wish to use?

View 1 Replies

C# - TryUpdateModel Not Working With Prefix And IncludeProperties

Aug 9, 2010

i have an entity called User with 2 properties called UserName and Role (which is a reference to another entity called Role). I'm trying to update the UserName and RoleID from a form which is posted back. Within my postback action i have the following code:

var user = new User();

TryUpdateModel(user, "User", new string[] { "UserName, Role.RoleID" });

TryUpdateModel(user, new string[] { "User.UserName, User.Role.RoleID" });

However none of these updates the Role.RoleID property. If i try the following:

TryUpdateModel(user, "User", new string[] { "UserName, Role" });

TryUpdateModel(user);

The RoleID is updated but the RoleName property is validated aswell. That's why i'm trying to be more specific on which properties to update but i can't get any of the first examples to work.

View 2 Replies

ADO.NET :: Add A Prefix Value With Existing Value While Updating A Column In Sql?

Feb 10, 2011

how to add a prefix value with existing value while updating a column in sql??

View 4 Replies

SQL Server :: How To Remove Left Prefix

Feb 23, 2011

I Have many entries that have this 'HK' as a kind of prefix. in SQL Server table while i have nothing against HK, the sales person would like this HK removed. the name of this column is categoryname

HK-Dietary
HK-Jan

View 7 Replies

C# - Configure Table Prefix For MySqlMembershipProvider

Oct 5, 2010

I have MySqlMembershipProvider working with Asp.Net MVC. My question is how can I configure the table prefix... so instead of 'my_aspnet_' prefix on the tables, I want this to be either none or defined by me. My web.config:

<?xml version="1.0"?>
<add name="ApplicationServices" connectionString="server=localhost;user id=root;Password=*********;database=sparkSources" providerName="MySql.Data.MySqlClient"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership defaultProvider="MySqlMembershipProvider">
<providers>
<clear/>
<add name="MySqlMembershipProvider"
type="MySql.Web.Security.MySQLMembershipProvider,
MySql.Web, Version=6.3.4.0, Culture=neutral,
PublicKeyToken=c5687fc88969c44d"
autogenerateschema="true"
tablePrefix="ss"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""
applicationName="sparkSources"
/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>

View 1 Replies

Split The Word And Get The 4 Letter Prefix In C#?

May 24, 2010

i have a username= LICTowner.

i need to get the prefix from the word LICTowner i.e LICT.

how to split the word and get the 4 letter prefix.

in asp.net using C#

View 6 Replies

Web Forms :: Creating XmlElement With Prefix Namespace?

Feb 5, 2010

I am trying to create a xmlElement from my asp page. The result xml node should look like the following:

<str:nam ft:qsType="qsString">NAME_I</str:nam>

I am having some problem putting the "str" prefix before the tag-name. I tried doing:

[Code]....

I get the result as:

<str:nam qsType="qsString" xmlns:str="xmlns:str="urn:instec-corp.com:qsdatamodel:autostructs:v1""> </str:nam>

I am not sure how to get the desired result which should be:

<str:nam ft:qsType="qsString">NAME_I</str:nam>

View 3 Replies

Web Forms :: Listbox Item With A Position Prefix?

Nov 7, 2010

I am trying to find the most efficient way to prefix listbox item text with their current index.I have two listboxes on a page, the first holds a list of states, the second holds the selection of states. When the user selects a state into the destination listbox, the state should be prefixed with the current index position. The destination box is sorted, and also has buttons to change the item positionsIs there a way to get the index of the item after insertion, instead of looping through the entire collection to add the index?

View 2 Replies

Fixing MaskedEditExtender To Prefix Date With Correct Century?

Jun 22, 2010

I am using a MaskedEditExtender on a textbox to verify a date. MaskType="Date" Mask="99/99/9999". Users of the system are used to typing just the last two digits of the year (i.e. 22/06/10) so I am trying to make this possible.

I have tried using Century="2000" but this option does not seem to function at all (still results in 22/06/0010).

A response in another forum suggests modifying the MaskedEditBehavior.js file to fix this behaviour - see here.

My question is, how should I go about modifying the MaskedEditBehavior.js file (as suggested in the link above), and how do I ensure that this modification is distributed with my application? I cannot even find this file to modify.

View 1 Replies

Web Forms :: Create A Function For Prefix Generation On Each Insert Row ?

Jan 19, 2011

How to Create a function for Prefix generation on each insert row ?I have a table with ID as primary and is identity and increment by 1. and POID another column.Now I need to generate a function like this.In POID Column on each insert I need to set prefix like this

PI000001
PI000002
PI000003
PI000004
PI000005
PI000006
PI000007
PI000008
PI000010
PI000011

and so on ......like this and so on ....

View 5 Replies

Web Forms :: How To Remove Master Page Prefix From Control ID After Rendering Content Page

Jun 26, 2010

how to remove master page prefix from control ID after rendering content page

i m using master page in my web application, i am using a java script that works on one of my div id and i am genrating div at run time using C# code, problem is that one one of my content page rendred a prefix ct100 attached on that div,

How can i remove that prefix from my server side control (assume panel) id

View 2 Replies

Why Does HtmlActionLink Always Prefix The Urls With The "Blog"

Feb 7, 2011

i have defined the following Routes:

routes.MapRoute("Blog",
"Blog/{controller}/{action}",
new { controller = "Test", action = "Index" });
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

When i call http://localhost/ all Links are wrong and go to the Blog: @Html.ActionLink("About", "About", "Home") creates the following URL: localhost/Blog/About but it should create localhost/About. Why does HtmlActionLink always prefix the urls with the "Blog"?

View 1 Replies

Configuration :: Redirect To URL Not Working With "www" Prefix

Feb 20, 2011

[Code]....

I'm trying to redirect a domain to a sub-directory. It works for. [URL] but is not working for [URL]. Do you know what I need to modify in my web.config redirect code above to make [URL] work?

View 4 Replies

Visual Studio :: Unrecognized Tag Prefix Or Device Filter Error In Visual Studio 2005?

Dec 13, 2010

I am building master page in visual studio 2005 and I have placed contentplaceholder into between <head> and </head> tag of master page, but in source view of visual studio 2005, I am getting error that says "unrecognized tag prefix or device filter" how do i get rid of this error or is this bug in visual studio 2005

View 2 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

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







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