asp.net-mvc

How to create subdomain with username using C# and asp.net?

When a user registers with my site, they will get a url like this "http://username.mysite.com" to access their page/folder. How this is possible using C# and asp.net mvc. Any help is appreciated. ...

How to have folder and controller with same name in ASP.NET MVC?

I have a MVC controller called Downloads. http://mysite/Downloads I also want to put a physical file in a physical folder called http://mysite/Downloads/MyFile.zip. If I simply create a folder, I get a 403 when browsing to http://mysite/Downloads. (Most likely because of directory browsing is disabled) But I want the MVC controller to ...

ASP.NET MVC - How to get random records from model?

Hello there, I don't know if there is an easy way to do it but basically what I would like to do is: var highlights = db.Banners.Where(h => h.Category == "highlight").ToList().GetRange(0,4); I have this model Banners where I have some highlights but I would like to retrieve just 4 random highlights each time in different order. So th...

asp.net MVC action link need to have the registered on the actual word

hiya got this actionlink: <%= Html.ActionLink("Corian&reg; Worktops", "Index", "Corian")%> the word corian has to carry the registered symbol or the word can not be used, but it seems to process, i know i could just write this as a normal href but it kinda defeats the object if there is another solution. has any tried and successful...

Is it possible to create a Logon System with ASP.NET MVC but not use the MembershipProvider?

I have an existing database with a users table, and we are planning to take the database and use it for a new system built in ASP.NET MVC. However, what I am uncertain about is whether or not I am able to create a login system that doesn't use the built in account controller or a regular membership provider so that we can still use the e...

Areas, Views, Shortcuts

Please take careful consideration when reading this as I can see it getting easily confused. Our current system has a set of menu options which are divided into areas (it's the areas of our business, in the same way you'd have accounts, personnel etc.). Some of these areas have blurred edges, i.e. a page may belong to both accounts and...

ASP.net MVC HtmlHelper in VB.net

Hi, stupid question here. I'm trying to create a helper method, something similar to the radio button list in the MVC futures project (as a learning tool). I'm trying to convert the C# code: public static string[] RadioButtonList(this HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes) { to a method sign...

Populating a SelectList from a DataTable

I ran a query and returned a datatable, myDataAdapter.Fill(myDataTable); Now what is the best way to load the row values "Value" and "Text" into a SelectList? Thanks ...

Does MVC Contrib fulfill its promise of increasing productivity in ASP.NET MVC

I am knee deep in starting a new ASP.NET MVC project. Several tutorials have recommended the use of MVC Contrib. I wanted to get the opinion of the Stack Overflow community if it fulfilled its promise of increasing productivity with ASP.NET MVC. Basically are the benefits of MVC Contrib worth adding another leaky abstraction to my applic...

ASP.NET MVC TagBuilder.SetInnerText() not setting the text correctly

So I am creating a HtmlHelper extension method and I have run into a problem when using TagBuilder.SetInnerText(). The helper outputs an option tag. Here is the source of the helper: public static string Option(this HtmlHelper helper, string value, string text, object htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("o...

ActionFilterAttribute - apply to actions of a specific controller type

I'm using an ActionFilterAttribute to do custom authentication logic. The Attribute will only be used on a derived Controller class that contains my authentication logic. Here's my Controller, derived from my custom controller class, and a sample attribute: public class MyController : CustomControllerBase { [CustomAuthorize(UserTy...

.NET MVC Using Javascript to Add Textbox to View on button click

I've tried searching around but there isn't something that is a fairly concrete example of this, and my 'jQuery-Foo' Is rather poor. Here's what I'm trying to accomplish: User is presented with a form in which they enter user data (first/last/address, etc). When it comes time to add a phone number, they need to be able to add as many...

Convert ActionResult to a URL string in a static method

When I have access to UrlHelper I can convert an ActionResult to a string (i.e. the actual URL) like this: urlHelper.RouteUrl(actionResult.GetRouteValueDictionary()); How can I do that same from a static method where I don't have access to UrlHelper? Thanks. ...

Using MVC and fluent Nhibernate, how do I validate unique fields on my ViewModel before I bind them to my Domain Object and Save them?

I have a website where I allow users to create new Part records. I'm trying to figure out the best way to validate specific fields for uniqueness. I want to make sure that somebody doesn't try to add a Part with PartNumber 1234 if that PartNumber already exists on a different Part. The Web Application is using Asp.net MVC with fluen...

Problems publishing website

Recently I've began experimenting with ASP.NET MVC and the Entity Framework. Since my hostingprovider only provides me with MySQL I've been trying to set that up. Locally everything works fine, but after I publish it I get the following error: [ProviderIncompatibleException: The store provider factory type 'MySql.Data.MySqlClient.MySqlC...

Databinding to non-created object (asp.net mvc)

I have an object that contains a collection of items, each item being another object. In ASP.NET MVC, I'm a little unclear about how to go about using databinding in my "Create" Views for this collection, since each object in it has to be created new. Any suggestions? Here is the schema. Units - UnitId Rings - RingId Keys - RingId (...

Is it possible to utilize the LINQ portion of the foreach inside the loop?

Hello SO: I have this view in an ASP.NET MVC application: <% var path = Path.Combine(HttpRuntime.AppDomainAppPath, "uploads"); foreach (var file in Directory.GetFiles(path).OrderBy(f => new FileInfo(f).Length)) { var item = new FileInfo(file); %> <tr> <td></td> <td> <%=Html.Encode(Path.GetFileName(i...

Is Ninject MVC supposed to work with MVC 2 Preview?

I am running a MVC 2 Preview and this is my first time trying to use Ninject2 MVC There error that I am continently getting is: An error occurred when trying to create a controller of type 'MyMVC.Controllers.EventsController'. Make sure that the controller has a parameterless public constructor. What I have in my Global.cs is this: pu...

Why can't I foreach through my ViewData or Model?

I keep getting errors trying to iterate through my ViewData in the view there... I even tried strongly typing the view to IEnumerable(App.Models.Namespace) and using Model, to no avail. Either I get an error for lack of a GetEnumerable method or invalid type casting... Any idea how I do this? Model... public IQueryable<Product> getAllP...

Prevent Caching of Attributes in ASP.NET MVC, force Attribute Execution every time an Action is Executed

According to various articles (e.g. here and here) attribute results on ASP.NET MVC Actions may be cached and not executed again when a controller action is called. That behavior is not desired in my case (e.g. I have an authorization system based on my own attributes and IPs, role checks that need to execute every time, and other thing...