asp.net-mvc

What is the best way to do automatic transactions with Asp.Net MVC?

I'm getting annoyed with writing the following code all over the place in my MVC app. using(var tx = new TransactionScope()){ blah... tx.Complete() } I'd like to make this DRYer somehow. I've thought of a couple different options for this. An action filter to declaratively mark certain actions as transactional. Override OnAct...

DesignPatterns: Which is most appropriate to use for a wizard style user interface?

I am implementing a Wizard style user interface. As a user flows through the wizard, clicking next, depending on the choices they have chosen on each screen, the user will have to go through a certain set of wizard screens. This is being built in ASP.NET MVC. I am wondering what design pattern would be best suited to implement the l...

Generated image display vs. download

I have an MVC action that pulls an image from a database and sends it in the response via the File(byte[], string) method. When I navigate to the action in my browser, it downloads the file rather than display it in the browser. I'm setting the file and setting the content type to "image/jpeg". Is there another header that needs to ...

How do websites use hitcounters to drive traffic

I am looking for a way to keep track of the number of hits to a particular webpage. When the number of hits reaches a certain number traffic is driven to a different web page. Specifically I could use this to mod the number of hits by different values and drive people to different webpages on this logic. Do free web traffic analytics sof...

How can a formcollection be enumerated in ASP.NET MVC?

How can I enumerate through all the key/values of a FormCollection (system.web.mvc) in ASP.NET MVC? ...

How do I get Ajax form submissions to work in ASP.net MVC?

I'm very new to the AJAX and Javascript world and I'm trying to implement Scott Hanselman's example of form submission to update part of a page. I have copied his example almost word-for-word and I can't seem to get it to work. When I click the submit button the controller action is called successfully but the result is rendered in the b...

Submit button doesn't work for ajax form rendered in dynamic partial view

I have some jQuery that loads a partial view and inserts it into the DOM. So far, all good. But now I've made some changes to the rendered user control to include an Ajax form. However, the submit button for this form doesn't appear to trigger the Ajax call. From what I can tell, it's not doing anything at all. My breakpoints in the con...

How can I rotate a line of text each page refresh?

Right now, Reddit is down. Every time you go to it, it displays a logo and below it a funny message. Every time you refresh the page it displays a new message. How could I write something simple that ~rotates~ (not random) a line of text on the page every refresh? I'm using ASP.NET MVC but if there is a JavaScript solution to this ...

ASP.NET MVC Storing Page Specific Settings

I am writing a learning project in ASP.NET MVC. I have a page "Books" that display a user's books and there are a few sorting and filtering options in that page like this. Book Page Sorting Parameters : Title, Year,Author... Filtering Parameters : Read, Unread ... When user selects a sorting parameter like "Title", Controller sort...

ASp.NET MVC doesn't call global.asax' EndRequest

I am trying to perform some actions at the end of every request. I changed the Application_Start() that is generated when created new project to make a test: protected void Application_Start() { EndRequest += (s, e) => { Console.Write("fghfgh"); }; RegisterRoutes(RouteTable.Routes); }...

getting route to controller action (url) programmatically

I have a controller named "AccountController" and action called "ResetPassword". From the html markup I can do something like: <%= Html.ActionLink("LinkText", "ResetPassword", "AccountController") %> and it will output the correct url. Is there a way to do this programmatically? I am trying to get the url as a string in another class...

Linq2Sql Pipes and Filters on inner list object

I'm using Linq2Sql with pipes/filters. My database consists of Accounts and Transactions tables where each Transaction row is linked to an Account. When displaying an Account I want to show the Account with all its Transactions. Simple enough. Now I am trying to limit the transactions that are shown by /accounts/4/{year}/{month}/{day} f...

How to change the default route point static html files in asp.net mvc

how can we point the default file to something like index.html instead of the default action Home/Index ...

Async in MVC

I have this webservice which is sucking in data about exchange rates, my problem with it is it takes alot of time to load. So i want to get the data loaded async but when i call the GetRatesASync() method it says "Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async a...

Implementing search on an ASP.NET MVC website

I've created a content-managed website using ASP.NET MVC. All content is stored in the 'Content' table in a SQL Server database, with the text itself stored in a column of datatype 'XML'. I want to add a search feature to the site that will search all the XML content and return a list of results, each of which links to the content item....

My code is riddled with service interfaces!

Hey all. I'm coming across a weird design pattern using the repository and service model. The application constists of ASP.NET MVC, WCF, and some Windows services. My repositories are using LINQ DataContext. As my application evolves I'm finding myself passing references to IWhateverService service everywhere. For example, I have IA...

Basic AJAX example with ASP.NET MVC?

I'm in the process of making a demo ASP.NET MVC app for educational purposes. I have an image/link that flags a post as offensive. I would like to request from the server via AJAX to flag offensive and check to make sure that the user has this ability. If the user does, then I want to flag the post as offensive in the database and r...

ASP.NET Tracking Code & Unique Visitors

Hi Guys, I am trying to find a way to track and produce reports for my site (out of interest). Does anyone know of any articles/projects etc that you can Track pages / unique visitors etc Tracking 1) relative to timestamp etc in asp.net mvc or just asp.net ? P.S - I know google analytics etc is available but looking to create some ...

display a calendar year with custom hyperlinks in asp.net mvc

I'm looking to create an MVC web page that displays the 12 months of the year in a calendar format. Inside each day in the month I will bold only the dates that have any activity (data from database). The dates with activity would also be hyperlinked to a route like /Activity/2008/12/25 i'm about to attempt to try the asp.net ajax contr...

File upload MVC

Hi, With the following markup in my view: <form action="Categories/Upload" enctype="multipart/form-data" method="post"> <input type="file" name="Image"> <input type="submit" value"Save"> </form> And in my controller: public ActionResult Upload(FormCollection form) { var file = form["Image"]; } The value of file is null...