C# - How To Modify MapRoute (add New Dir)
Mar 26, 2010
How can I change my map route so I can have another dir, and not just the controllers and actions.What I want is to have another directory before the controller so that way I can separate controller per "module"
routes.MapRoute(
"Default", // Route name
"{module}/{controller}/{action}/{id}", // URL with params
new { module = "module", controller = "controller", action = "Index", id = ""}
This is what I want, but the code doesn't work. What more do I need to change to change the MapRoute?
View 2 Replies
Similar Messages:
May 12, 2010
My routes work in the Global.asax, but I created an Area called Dashboard and while it works with the default route, it doesn't when I implement the T4MVC route.
Here's my Dashboard Area Registration class:
[Code]....
If I view this in a browser with the above settings, any Html.ActionLinks render as empty strings, no routing at all.Here's the rendered HTML from the route.
[Code]....
View 8 Replies
May 6, 2010
What is this namespaces argument for? It seems to have no impact at all. I have two controllers called ClientUser in seperate namespaces of the same assembly. I specify told the route to look in the *.ClientUIControllers namespace and all I get back is:Multiple types were found that match the controller named 'ClientUser'. This can happen if the route that services this request ('{controller}/{action}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
The request for 'ClientUser' has found the following matching controllers:
RWA.Web.AdminUIControllers.ClientUserController
RWA.Web.ClientUIControllers.ClientUserController
To be clear I am not actually passing MapRoute the namespace but am instead setting this after the call:
route.DataTokens.Add("namespaces", new string[] { controllersNamespace });
I tried to debug MVC2 but it all got a bit too abstracted and with annoying limitations of debugging release build it got too hard. I got up to ControllerTypeCache.GetControllerTypes but I couldn't follow it. I can see that the specified namespace was definiately in the namespaces arg.
View 3 Replies
May 19, 2010
ASP.NET MVC's MapRoute method has a parameter named namespaces. From looking in the code, I see that this parameter is saved in the Route object
in DataTokens["Namespaces"].
It seems to me that it has some meaning... anyone knows what is it for?
View 2 Replies
Jan 26, 2011
I'm wanting the URL to my MVC application to be like:www.site.com/BobWhich would in turn 'redirect' to Home/Details/Bob.I've set up the following MapRoute:routes.MapRoute( _Nothing, _"{personName}", _New With {.controller = "Home", .action = "Details", .personName = ""}, _
New With {.result = New NameConstraint()} _
View 1 Replies
Nov 29, 2010
This two maproute maps to the same controller, how to check in the controller which maproute it was called from?
routes.MapRoute( _
"Categories", _
"category/15", _
[code]...
View 5 Replies
Mar 30, 2010
As I was trying to create an MVC 2.0 application and map nested areas, I ran ran into a lot of issues mapping routes. So, after I troubleshot all of the bugs, I decided to make a screen cast.Solution Files can be access here: MVC 2.0 AreaRegistrationContext RouteMap Demo Solution FilesVideo tutorial of how to Map Areas.[URL]
View 3 Replies
Apr 15, 2010
I have registered the following SEO friendly route:
[Code]....
Anyone an idea how to fix this problem? Returning a 404 is not a nice UX when (in our case) only the id really matters ...
View 7 Replies
Jun 26, 2010
I am doing some research on themes in asp.net. (Just Learning) is this a practical use of my time? Should I just use css files and if someone wants to modify anything let them use the css to do it? Are themes a waste of my time? I really want to create my app but give the end user the ability to customize the look and feel without jumping through hoops. Can someone push me in the right direction with pros, cons etc
View 3 Replies
Jan 20, 2011
I've different buttons like this
<asp:Button ID="button1" runat="server" Text="single" title="single" EnableViewState="false" />
When this button is clicked I want that the text in a list like this changes
<asp:BulletedList ID="list1" runat="server" EnableViewState="false">
<asp:ListItem>Item1</asp:ListItem>
<asp:ListItem>Item2</asp:ListItem>
<asp:ListItem>Item3</asp:ListItem>
<asp:ListItem>Item4</asp:ListItem>
</asp:BulletedList>
How in C# can I select the first, the second or the third element of the list?
protected button_Click(object sender, EventArgs e)
{
list1. ...;
}
View 1 Replies
Jan 12, 2011
I'm trying to call a dataset, modify a value, and then put it back into a dataset.
I think this is possible but I'm doing something wrong
attached is an image of the table and the code
[Code]....
View 3 Replies
May 12, 2010
I know this is a common request, I've googled loads but found lots of complicated code for such a simple task.
My basic insert code is below, can someone tell me how/ where I can modify it to get the last ID?
[code]....
View 7 Replies
Apr 2, 2010
My application uses the default URL http://tempuri.org rather then using specific URL. In my C# code, how do I change the SoapAction? Is it in the ServiceContract? OperationContract? I'm not sure.
This is in the binding level.
View 1 Replies
Dec 23, 2010
I am trying to embed a visio doc in an aspx page using the following code
<OBJECT classid="CLSID:279D6C9A-652E-4833-BEFC-312CA8887857"
codebase="http://download.microsoft.com/download/4/5/2/452f8090-413f-408f-83c0-edd66db786ee/vviewer.exe" [code]...
i need to modify the value parameter SRC from code , how do i go about it ?
View 2 Replies
Oct 24, 2010
How can one modify DomainService code without the custom code being overwritten?
Is there a way to put the custom code in a seperate class file?
View 1 Replies
Feb 16, 2010
how to do routing. My problem basically relates to "logged in" and "logged out routes" and having both as "/".
i.e. I have home/index for logged out user which appears as "/" but this has got me confused as to how I can have home/home for logged in user and still have "/".
I keep getting 127.0.0.1/home/home
I could modify like 127.0.0.1/home - but I want it like "/". My confusion relates to the fact that the "/" [127.0.0.1/] is bound in the routes collection to home/index.
how I can modify the routes dictionary (which will be binded ONCE at the start) so that the "/" can be shared for logged and non-logged users ?
View 8 Replies
Feb 24, 2011
I want to hide or modify the url extension by default it is set to aspx. Can it be modified in asp.net
View 2 Replies
Feb 12, 2011
I have a C# web application (VS 2005).
I need to open an existing text file and add data to each row.
View 4 Replies
Oct 21, 2010
I wrote the following code to preserve the values of a dynamic array
but the 2nd time around I get the 'ReDim' can only change the rightmost dimension.
Here is the code ...how should I modify it? Initial lead_count value is 0
[Code]....
View 1 Replies
Apr 19, 2010
I m trying to modify a .aspx page which i think is precompiled.(Whenever i open any aspx file it contains following "This is a marker file generated by the precompilation tool, and should not be deleted!").Is there any chance that i can modify source and add a little scriplet inside it?
View 6 Replies
Apr 15, 2010
I have a literal control on a page that gets it's value from a resource file like this...
<asp:Literal ID="Literal2" runat="server" meta:resourcekey="Literal2Resource1"></asp:Literal>
The resource file contains the following HTML code...
<a runat=server id="bylchau" href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306">Bylchau</a>
Therefore when the page is loaded it renders a hyperlink to the page.
What I want to do, is modify the href of this hyperlink after the page has loaded (in Page_LoadComplete??)
Have tried the following but get error, 'Object reference not set to an instance of an object.'
Dim quicklink As HtmlAnchor = DirectCast(Form.FindControl("bylchau"), HtmlAnchor) quicklink.HRef = quicklink.HRef + "boo"
What I was hoping for is that the href of the anchor would change to href="./pothole_locator_map.aspx?lang=en-gb&lat=53.153977&lng=-3.533306boo"
View 9 Replies
Jan 5, 2010
I'm thinking there has to be an efficient and OO way to do this.
I have several textboxes on a data entry page. When I need to make a new entry, I have to clear the text field before making new entries and this has to be done for quite a number of textboxes and across several pages.
Is there a way to use the FindControl method to locate all textboxes on a page and clear their textfields probably using a loop of some sorts?
View 2 Replies
Aug 21, 2010
I'd like to record more information than the default control allows as well as perform actions with the input when the form is submitted but I'm having trouble figuring out how.
So firstly, if I want to record the middlename for example, how would I do that, and by default, where would it go if anywhere?
When the form is submitted, I'd like to take specific input, such as just the middlename for example, and write some linq to sql code to specify when and how it's stored. In what event would I put this code?
View 3 Replies
Mar 20, 2010
I retrieve a record on my database through Page_Load event here's the content of my Code:
hMenuID.Value = Request.QueryString["id"];
//Display information of links on the entries
cnDBConnection.ConnectionString = clsFunction.strConnection;
cnDBConnection.Open();
cmModule.Connection = cnDBConnection;
cmModule.CommandText = "SELECT * FROM modules WHERE id=" + clsFunction.ReplaceString(hMenuID.Value.ToString());
rdModule = cmModule.ExecuteReader();
if (rdModule.HasRows == true)
{
rdModule.Read();
txtModuleLabel.Text = rdModule["name"].ToString();
txtModuleLink.Text = rdModule["link"].ToString();
cboParentID.SelectedValue = rdModule["menuid"].ToString();
}
cmModule.Connection.Close();
rdModule.Close();
cnDBConnection.Close();
So, the data appears on my textboxes and a combo box. I tried to modify the content of my textbox and click on the Update button. Unfortunately, there's no modification that happen. Here's my code in the Update button
Code:
if (Page.IsPostBack)
{
if (Page.IsValid)
{
cnDBConnection.ConnectionString = clsFunction.strConnection;
cnDBConnection.Open();
cmModule.Connection = cnDBConnection;
cmModule.CommandText = "UPDATE modules SET name='" + clsFunction.ReplaceString(txtModuleLabel.Text.Trim()) + "', link='" +
clsFunction.ReplaceString(txtModuleLink.Text.Trim()) + "', menuid=" + cboParentID.SelectedValue +
" WHERE id=" + hMenuID.Value;
cmModule.ExecuteNonQuery();
cmModule.Connection.Close();
cnDBConnection.Close();
}
}
View 6 Replies
Mar 25, 2010
I am using ASP.NET MVC2 (and I am new to MVC).
I created a new MVC2 project and use the SqlMembershipProvider and Forms Authentication but am not using Roles (yet). Each user has additional information associated with them (e.g. Company) which is stored in a different table than the aspnet_* membership tables.
I store an additional small piece of information in the authentication cookie (e.g. CompanyId), and create a custom identity object during the AuthenticateRequest event and this custom identity object exposes the CompanyId as a property. Thus, CompanyId is available in controller actions that has been decorated with [Authorize].
When creating a new user, I now want to create this additional user information (e.g. Company) and associate it with the user. I realize there are many different ways to do this but since I am fresh to MVC I am soliciting advice about the best way to do this - I want to do it in the best "ASP.NET MVC way".
One option would be to change the AccountController's Register action and after a successful call to MembershipService.CreateUser(), do the work to create the additional info in the database. Doing it this way does not require any modification to IMembershipService etc.
Another option would be to modify the IMembershipService interface (add a "company" or "companyName" parameter to the CreateUser() method), then modify AccountMembershipService's implementation of CreateUser() and do the work to create the additional info in the database there.
And yet another option would be to leave IMembershipService alone and instead create my own IMyMembershipService and MyAccountMembershipService and use those.
View 3 Replies