asp.net-mvc

How do I a preselect an item in a List(Of SelectListItem) for DropDownList in ASP.NET MVC VB.NET

I have a List(Of SelectListItem) and I fill it with NativeName as .Text and the two letter ISO region name as .Value. Dim countryList As IList(Of System.Globalization.RegionInfo) = GetRegionInfosForEuOnly() Dim dropDownCountryList As New List(Of SelectListItem) For i As Integer = 0 To countryList.Count - 1 dropDownCountryList.Ad...

MembershipPasswordFormat.Hashed? How does this work?

Straight to the point: Where can I place the algoritm for password hash encryption in Membership Provider? or: Where did Microsoft team place the encryption method? Because: I chose to have it Hash but password ended up in my database are plain. Thank you very much :) ----- Update Sorry for not mention, im using my own custom provid...

How to add other Open ID providers to OpenIdRelyingParty?

I'm trying to implement a relying party (the web site I'm working on) using DotNetOpenAuth on ASP.NET MVC. I'm using the current version 3.3.1. Using the included MVC sample, I can see that the OpenIdRelyingParty class can automatically recognize and redirect to some open ID providers such as myopenid.com and Yahoo based on the ID spec...

Custom validation with Data annotations

Hello I'm having problems with getting my custom dataannotations to work, I'm trying to add a validation-attribute that validates that the UsergroupName for a Customer (CustomerID) is unique. [MetadataType(typeof(UsergroupMetaData))] public partial class Usergroup { } public class UsergroupMetaData { [Required()] public object...

Project Layout and Site Structure in ASP.NET MVC

I'm new to ASP.NET MVC and would like to create and deploy a website using ASP.NET MVC. I have a few old sites that run classic ASP and the site-structure goes like this: web.root (holds website pages) data.files (holds databases) log.files (log files) I was wondering if the same structure is used for ASP.NET MVC?? What’s the best ...

How to delete file after download with ASP.NET MVC?

I want to delete a file immediately after download, how do I do it? I've tried to subclass FilePathResult and override the WriteFile method where I delete file after HttpResponseBase.TransmitFile is called, but this hangs the application. Can I safely delete a file after user downloads it? ...

"if" considered harmful in ASP.NET MVC View (.aspx) files?

I remember seeing a blog (or something) that said you should not use <% if ... %> in .aspx files in ASP.NET MVC, but I can't remember what it said the alternative is. Can anyone remember seeing this and point me to it? ...

Using a different viewmodel in partial view using Spark view engine

Using ASP.NET MVC & Spark, I have a view that is listing a number of searches. The view has the following declaration at the top: <viewdata model="IEnumerable<SearchModel>" /> On the same search page, I also render a partial which is used as the content of a popup window that enables users to add new searches. My problem is: in the p...

jQuery and ASP.NET MVC - JSON Objects

Hi, I currently have a controller method that returns a JsonResult: public JsonResult EditField(int FieldID, string FieldValue) { var f = ManagerProvider.GetFieldManager(); try { f.UpdateField(FieldID, FieldValue); return Json(new { State = "Success", Message =...

How do I load views independent of the site.master?

I'm preparing an application I wrote in ASP.Net MVC for some light Ajax-y stuff. Basically, I want users to be able to go to different parts of the page without it reloading. To do this I want to be able to reload the body of my page. My site master is broken down into a head body and foot div. I want to be able to use something like ...

How to write custom client-side jQuery validation in ASP.NET MVC 2 RC?

I've read Phil Haack's post on custom client-side validation in ASP.NET MVC 2. I want to do the same thing but with the jQuery adapter and using ASP.NET MVC 2 RC (as opposed to MVC 2 Beta that the post uses). Has anyone been able to figure how to do this? I specially want to implement the password matching validation (i.e. password & ...

ASP.NET MVC Routing two GUIDs

I have an action taking two GUIDs: public class MyActionController : Controller { //... public ActionResult MoveToTab(Guid param1, Guid param2) { //... } } I would like the following URI to map to the action: /myaction/movetotab/1/2 ...with 1 corresponding to param1 and 2 to param2. What will the route look like, and ...

Navigation menu with highlight in Asp.NET MVC?

It's a simple question. How did stackoverflow do their menu in Asp.net MVC, with highlight on what page we are on. ...

What is the difference between a View and a PartialView in ASP.NET MVC?

What is the difference between a View and a PartialView in ASP.NET MVC? At first glance the need for both seems non-obvious to me. ...

ASP.NET MVC development with Notepad?

So do I NEED Visual Studio of some flavor to do ASP.NET MVC development or could I technically do it all with a simple text editor? If YES, please tell me the catches, like if there is anything special I would have to do besides making the folder structure right and making sure my code is solid, etc. ...

AuthorizeAttribute extension for .net MVC...two problems/questions

my first question is, where do I put this custom extension so that it can be called rather than the default AuthorizeAttribute? I currently have created a new project that contains all of my business logic within my MVC solution. I have a .cs file within my logic project that contains all of my security classes. I tried adding an exte...

How can a readonly static field be null?

So here's an excerpt from one of my classes: [ThreadStatic] readonly static private AccountManager _instance = new AccountManager(); private AccountManager() { } static public AccountManager Instance { get { return _instance; } } As you can see, it's a singleton-per-thread - i.e. the instance ...

Why is ViewContext.ViewName not available?

I read several examples on the web which use the following code: Private Function SomeFunction(ByVal htmlhelper As HtmlHelper) As String Dim controller As Controller = htmlhelper.ViewContext.Controller If controller IsNot Nothing Then Dim vname as String = htmlhelper.ViewContext.ViewName 'This doesnt work End If End...

Why isn't my Route.Ignore working on this static file in my ASP.NET MVC application?

Background I have a PDF file located (under my Project) in an Assets > Documents folder: When my application gets deployed, it gets deployed to a particular folder on the domain. For example, http://www.domain.com/MyAppFolder. I want to be able to access this PDF file by linking to http://www.domain.com/MyAppFolder/Assets/Documents/E...

clicking on a image submits the form by default?

I didn't realize this, and just want to confirm. If I have a html form, and an input tag of type image like: <input type="image" name="blah" src="..." /> Clicking on the image will submit the form? My use case is, I want to create a custom button for a submit button. ...