asp.net-mvc

how to Assign roles to User while creating his account.

hi all i am using asp.net built-in membership and role provider. In my application Admin Create account for user. currently i am assigning roles by going to asp.net configuration website. kindly tell me how to add an extra step of Select Role in creat user account API. Thanks. ...

unable to download dynamically created file.

Hi! I've created a custom Action Result in my MVC application, where I generate a CSV file according to the configuration that the user provides. However. The problem I have now is that if I create a download link like this: <a ID="lnkDownload" href="<%= Url.Action("DownloadFile", "Download", new { id = Model.Id, userId = Model.userI...

Custom user in ASP.NET MVC 2

Hi, I'm trying to implement a custom user object in ASP.NET MVC 2. I've seen a solution where you can do some magic in Global.asax to turn Controller.User into another type, say CustomUser. But Controller.User is still an IPrincipal, which means I have to cast it to CustomUser every time I want to use it, and I don't like that at all. ...

Parameters for webservice call from ASP.NET MVC/jQuery best practice

I need to call a webservice which takes as parameters things like the database name, schema name, login credentials etc. I'd ideally like to call the webservice directly from jQuery, but I feel that these parameters belong in the web config so perhaps I should be calling the webservice indirectly through an ajaxed MVC controller method....

structuremap objectfactory life time

Hi, i've been using structuremap since a couple of months. I always use ObjectFactory.GetInstance to take the right instance of the object i've to use. Actually, i need to understand which is the default ObjectFactory's InstanceScope. Is it ThreadLocal? do u know where i can read about it? ...

Extra If Statements Or Repetative Code in C#

Trying to figure out which makes more sense <%foreach (var item in Model.items) { %> <tr> <td> <% if (!item.isMgmt) { %> <a href="/MVC/AzureMail/Unfiled/<%:item.uName %>"> <%:item.uName%></a> <% } else { %> <%:item.uName %> <% } %> </td> </...

export IEnumerable<T> to Excel

anybody knows how or some library to use for this ? ...

Speed up page loading and information processing

On my web application I'm loading a page which can load up to 8000 or more rows in a table, each row having its own dropdownlist. This first process proves to be extremely inefficient but I was asked to do it like this. The code loading the rows goes below: <tbody> <% var i = 0; foreach (var row in Model) ...

Late binding operations cannot be converted to an expression tree with LINQ

I currently have a View in MVC where I pass a single set of data to the view. However, I've come across a problem where I am having to use a LINQ query within a For Each loop in the View to pull out additional information from a SQL View of data from another DB. The error I'm getting is Late binding operations cannot be converted to an ...

Restoring page results in ASP.NET MVC

Hi, I am working in ASP.NET 3.5 MVC application. We have a functionality where we search for say "Customer search results", using some parameters. If the user enter some search parameters like say, Date of birth/SSN/address, and hits search, the search results are displayed in a grid below. One of the records in the results can be click...

ASP.NET MVC 2: Why does my app reference both versions (1 and 2)?

I opened up the DLL for an ASP.NET MVC 2 project of mine in Reflector, and noticed that there are two references to System.Web.Mvc - one for version 1.0.0.0, and one for 2.0.0.0. I don't seem any references to v1 anywhere in the csproj file, nor in my web.config file, but when I try to run the app I get the error Could not load file or a...

Returning JSON data to view page in ASP.NET MVC

I'm working on MVC project and i using jQuery in view page to get data from controller. public JsonResult CheckUpdate() { dt = dt.AddSeconds(-100); IQueryable<Tweet> _tweet = ttr.CheckTime(dt); return Json(_tweet, JsonRequestBehavior.AllowGet); } This is a method in my controller which gets data back from the repository class ...

Adding Include Files to the Add Controller T4 Templates in ASP.NET MVC

Hi, is it possible to add include files within my custom t4 templates for the "Add Controller" dialog box? I have tried doing: <#@ include file="Helpers.tt" #> This is what you would typically do in t4 but this does not seem to work. Currently i have resorted to throwing all my helper functions in the footer of my templates but this...

ASP.NET MVC: Tracking Page Views and view Duration

I have an application I'm currently working on that requires Administrators to be able to track the views of a ticket and it's duration. I've got the tracking of the number of views by users sorted out, I have a table that contains a TicketID, UserID and a DateOpened. Each time a user visits the page, a new row will be inserted. Howeve...

ASP.NET MVC - Removing controller name from URL

Hi, I want to remove the controller name from my URL (for one specific controller). For example: http://mydomain.com/MyController/MyAction I would want this URL to be changed to: http://mydomain.com/MyAction How would I go about doing this in MVC? I am using MVC2 if that helps me in anyway. ...

Which strategy to choose for building web based business application

Hi everyone! I'm planing to create an accounting application in asp.net mvc. Each user will pay monthly subscription, I'll provide daily backups, etc. I don't know which strategy to choose: To use SQL CE4 and run application in separate virtual directory for each user. To put everything in a single SQL Server database What are cons ...

Rules Violations Exceptions in LINQ ASP.NET MVC

Possible Duplicate: First attempt at Linq to Sql in NerdDinner - Rule violations prevent saving Hello, I am using ASP.NET MVC application with LINQ and when I try to SubmitChanges after Inserting a table data I am Getting "Rule violations prevent saving". I am doing UpdateModel before submitting but that passes fine. I doub...

Is ViewPageBase the right place to decide what master page to load?

As you can tell from the title, I'm a n00b to MVC. I'm trying to decide what Master to load based on my route configuration settings. Each route has a masterpage property (in addition to the usual url, controller and action properties) and I'm setting the masterpage in the OnPreInit event of a ViewPageBase class (derived from ViewPage). ...

MVC Validation using Data Annotations - Model classes or View Model classes?

Is it best practice to put data validation annotations in the Model or View Model? What are the advantages/disadvantages of one approach over the other? Curious to see where everyone is putting their validation, I am currently doing it in the model project. However I have seen a few people say this is not best practice. ...

Linq Orderby random

i'm using Asp.net MVC with Sharp Architecture. I have this code: return _repositoryKeyWord.FindAll(x => x.Category.Id == idCAtegory) .Take(50).ToList(); How can i order by random? Note: i don't want to order the 50 extracted items, i want order before and then extract 50 items. thks ...