How To Allow Hyphens In URLs For Mvc 2 Controller Names
Mar 12, 2011
[ActionName("about-us")]
public ActionResult EditDetails(int id)
{
// your code
}
The above works for actions but I would like to be able to do the same (or similar) for controllers, ie have a hyphen in the URL name too. Is there any easy way to achieve this (I tried the ActionName attribute but no luck)
I have a question about URLS, I am creating a little app and using GUIDs from the primary key and identity and LINQ2SQL - So wondering how I would go about creating nice URLS? I don't want the guid in the URL which is what it tries to do by default.And I can't use a Name field as there may be duplicate names? I'm considering just creating another auto incrementing field in the table just for the URLs? Just wondering how everyone else handles this
I want to send FreeTextBox content (Both text and Images) via Email.when I check my email I can see text but inestead of Image there is Image name.this is html code when I add an image to FreeTextBox
<br><img src="http://localhost:4995/niceedit/images/butterfly-314-3.jpg" alt="butterfly-314-3.jpg" border="0" height="90" width="120"><br>Please look at srcand after click send mail button I check again html of freetextbox and you can see that below <br><img src="/niceedit/images/butterfly-314-3.jpg" alt="butterfly-314-3.jpg" border="0" height="90" width="120"><br>please compare two src
In my application I have controller named `Snippets` both in default area (in application root) and in my area called `Manage`. I use T4MVC and custom routes, like this:
I'd like to fully localize my ASP.NET MVC application, and while there are many articles that deal with the various pitfalls of ASP.NET MVC localization, none of them deals with an aspect that I want to deal with, and that is the localization of URLs, including the controller names and actions.
I would like a way to specify the strings that should appear instead of the controller name and action name in the URL, for example in a resource file.
I'm trying to learn MVC and I'm playing around with the MvcMusicStore tutorial.I'm trying to modify the StoreController to change some of the behaviours.I'd like to change the route behaviour from:
i have a function that pulls URLs from various web resources. needless to say some are full valid URLS and some are relative as per the HTML of the page. below is my asp.net/ c# logic i derived for examining the URL and then generate a full usable URL from whats pulled from the site...
NOTE: origianlurl is the full url of the first searched page, and relativeUrl is a url found within the searched page (it can be a full www.site.com or a /contactus.html) private string ResolveRelativePaths(string relativeUrl, string originatingUrl) { if (relativeUrl.StartsWith("http") || relativeUrl.StartsWith("www")) return relativeUrl; if (relativeUrl.StartsWith("/")) { //get main url something.com [code]...
I am attempting to compare one of ASP.NET's membership userID's with the current userID in an SQL query, however because of the "hyphens -" in the uniqueidentifier field type of userID, i am unable to compare the ids. is there a way around this? (in my example, family_id from tblFamily is the userID that has type uniqueidentifier). my code as it stands is:
Dim UserID As String = New String(Membership.GetUser(User.Identity.Name).ProviderUserKey.ToString()) Response.Write(UserID) Dim strConn As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString Dim SQLI As New Data.SqlClient.SqlCommand("SELECT family_name FROM tblFamily WHERE [family_id] IS " & UserID & "") Dim sqlCon As New Data.SqlClient.SqlConnection(strConn) sqlCon.Open() SQLI.Connection = sqlCon Dim RSI As Data.SqlClient.SqlDataReader = SQLI.ExecuteReader() RSI.Read() Dim FamilyName As String = "0" While RSI.Read FamilyName = Convert.ToString(RSI("family_name")) End While Response.Write(FamilyName) RSI.Close() sqlCon.Close()
Using a RegularExpressionValidator, I want my textbox to accept a max of 20 chars, and only English characters A-Z (upper and lowercase), 0-9, hyphens (-), underscores (_), and spaces. That's it.
Now that I think about it, since this text will be used by a proprietary software to create a file of the same name, and will also be included in the querystring when the page is redirected (so that I can find the file so the user can download it), I'm not sure if I should keep it safe and not accept spaces.
I have been working with this database for some time. Here is the situation...
I inherited a MS SQL database that has hundreds of tables with similar data. For instance:
FordTampa_customer is a table,
ChevyAtlanta_customer is a table, etc....
All of the columns are the same...just different tables with their own ID field. All I have done...Inside of another database id is created a table called 'Customer' and added an 'Dealer ID' column along with the rest of the other columns in the other tables...
So the combination of the 'Dealer ID' and the 'ID' field are unique.....I know...its not the best way to do things...but I cannot change the old data structure because I cannot have access to it. I am give back-ups on a weekly basis, so this is all I have to work with.
All right, on to the real point of my post...
Currently, I have an application that I use to select all of the data from the 'Ford_customers','Chevy_customers',etc... and inserts them into my new main 'Customer' table. I do this by selecting the table names, bind it to an arraylist, loop through the list and execute an insert statement.
I do this in VB.NET, but I would prefer to do it in a Stored procedure of some kind....I just am not sure how to accomplish it. I use this syntax to get my list of tables:
[Code]....
I am not sure how to take those names from the table and do another select based on that list of names.
UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development, that follows the UP(Unified Process). It uses a Grasp Controller pattern to interact with domain classes by some methods like NewSale(), AddNewItemToSale() and CloseSale. In windows form, I can instantiate a object of this class in the UI and then use its methods to perform the actions. This works well in Client apps, but when I use asp.net mvc, I cannot find a way to instantiate an object (one for each user) that was always visible for a Controller (MVC). I cannot insert as an attribute inside Controller because it always create a new one.
my MVC2 delete and only my delete controller is refusing to return any class information. Its really similar to my edit function and the views are all auto-generated so I don't see the problem.
Function Delete(ByVal id As Integer) As ActionResult
I have a simple model where a Person has Gifts. I have a view which is a list of Gifts belonging to one Person.
My problem is with the Create action for a new Gift. I want it to default to the PersonID that we are already viewing the list of Gifts for. I tried simply passing the last PersonID (they are all the same)
Html.ActionLink("Create New", "Create", new { id = Model.Last().PersonID }) which works fine if there is already at least one Gift for that person but if this is the first Gift I don't have a value.
My Gift List controller knows the PersonID I want to pass but the view doesn't.
How do I pass this PersonID from my Gift List controller to my Gift Create controller via the Gift List view? Or is there a better way to do this?
I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.
How can I persist values from controller to controller?
Should I use Session? TempData?
I am using Structure Map for IOC.
Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?
I have a User entity and a department entity. I have a UserViewModel and DepartmentListModel which has List of departments.
UserViewModel has a property of type DepartmentListModel .
Now on user/create action I need to populate DepartmentListModel by calling DepartmentController's list action. List action returns populated DepartmentListViewModel.
From UserController how do I set DepartmentListModel ?
Even to achieve the first link above, I need to replace capital letters and non-standard characters like é with e, and replace spaces with hyphens. Is all of this possible using URL Rewrite Module 2.0 or might I be better off coding some ASP? I'm new to .net and may have to do something in classic if I struggle. And I only just get by in ASP...
I've tried some of the tutorials on the official IIS website and have got through a simple rewrite wizard, but replacing characters seems more complicated, and I'm sure some of the tutorials have errors in them...
I have a application which uses intelligencia urlrewriter to rewrite urls into seo friendly urls. Blog engine is integrated in this application under subfolder but shares webconfig with my application. Application runs perfectly on development server, but when i publish it to 2008/IIS7 server urls links don't work. Links similar to following work
Anything which has query parameters in aspx url fails. I'm not sure what is causing this error on 2008/IIS 7 server and not on my VS 2008 development server.
I am using asp.net and when I type a bad url manually(in the browser) it gives me: The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. I want a bad url that doesn't exist to be re-directed to the home page. How do I do this?
I am using the NerdDinner project to experiment with MVC. http://nerddinnerbook.s3.amazonaws.com/Intro.htmI have put an image map on the front page and cannot work out how to generate the urls for it.
if I choose without dash, when I try to access [URL] it will return a 301 to the link without dash: [URL] The question is, how can I do that with ASP.NET MVC?
I know the default routes in MVC include an id param which often maps to the identity of an entity as it's stored in the database. Now, often this is OK, but what about when you don't want someone to be able to manipulate it? Quite frankly, on many business apps this is very common. For example, you don't want someone to change the account number (not the best example, but you get the idea) in the URL for obvious reasons. So, you would need to validate the account number against the logged in user on every request. Obviously, that is not a realistic solution, and in webforms many people would store something like that in session. I am trying to rely on session very little in MVC, but aside from that would I just go old school and use hidden fields