asp.net-mvc

What's the point of ASP.net AJAX in ASP.net MVC?

So ASP.net MVC by default ships with both JQuery and ASP.net Ajax. While the use cases of JQuery are obvious and plenty, I just wonder what the point of ASP.net Ajax is? If I just have my Controller Actions return JSON, I don't need it? Also, any "old" ASP.net controls only work if you use the Webforms view Engine (I think I want to use ...

Should I send e-mails in the service layer or in the controller layer?

I am using the MVC pattern in ASP.NET using service (BLL) and repository layers for data managment. In some cases, I want to send out an automatic e-mail when a new request is sent through our website. In what layer of the architecture should this e-mail be sent? In the controller layer or the service layer? I was thinking the service ...

ASP.NET MVC Routing to start at html page

I am using IIS 6. I think my problem is that I don't know how to route to a non controller using the routes.MapRoute. I have a url such as example.com and I want it to serve the index.htm page and not use the MVC. how do I set that up? In IIS, I have index.htm as my start document and my global.asax has the standard "default" routing...

ASP.NET MVC on Cassini: How can I force the "content" directory to return 304s instead of 200s?

Scenario: I have an ASP.NET MVC application developed in Visual Studio 2008. There is a root folder named "Content" that stores images and stylesheets. When I run locally (using Cassini) and browse my application, every resource from the "Content" directory is always downloaded. Using Firebug, I can verify that the web server returns an ...

ASP.NET MVC shows ajax result in a new page instead of UpdateTargetId

I am using Ajax.BeginForm to make an ajax request but asp.net mvc displays results in a new page instead of the div I set in UpdateTargetId. I ensured that I have only one div with the same name on the page. The generated markup is: <form action="/MyController/MyAction" id="myform" method="post" onsubmit="Sys.Mvc.AsyncForm.handleSubmit...

ASP.NET MVC Routing construct links based on current url

I have urls that look like this ~\articles\energy\topweek ~\articles\metals\latestpopular where second url string is a category and third is a filter so route looks like this routes.MapRoute("ArticleFilter", "articles/{category}/{filter}", new { controller="Article", action="Filter" }) That's pretty easy and everything ...

Problem using XmlSerializer to Serialize/Deserialize a class between a Silverlight Library and an MVC App

Here is my situation: I have a solution with three projects: 1) Silverlight App, 2) Silverlight Library, 3) the Asp.net-MVC Web App. In the Silverlight Library I have a class called "MyClass". In the Silverlight App I serialize that class to XML using XmlSerializer and send the XML back to the database. I retrieve and deserialize tha...

Best way to use one control in two forms

I'm trying to create a page where a user selects the type of subscription they'd like to purchase and then either enters their credit card info or hits the "Pay with PayPal" button. So far, the best way I could think to do it was to have a single drop down where the user would select the subscription type and then two forms side-by-side...

Get the display value from a DropDown

I'm trying to access the values in the FormCollection inside of an action. I can get the value field by doing: var value = formCollection["MyDropDownList"]; But I can't seem to find a way to get the display value. Am I missing something obvious? A cast perhaps? ...

Using images on Web Applications and Visual Studio for ASP.NET MVC

Hi all, I am developing an ASP.NET MVC applications with MS Visual Studio 2008 SP1. My project structure is the default one: Project |-Content |-css |-img |-Models |-Views |-Controllers The thing is, I am able to access all the content placed under Content directory provided the file is included in the project. On the o...

Jquery Ajax not failing after unauthorized post

i have a jquery .ajax post type Json and an MVC controller with an [Authorize] attribute. on the return Jquery carries out "success" if user is authorized, but never carries out the "fail". how to handle when user is not authorized? $.ajax({ type: "POST", url: "/index", dataType: "json", ...

How do I get the exception message from a failed jQuery request?

If I use jQuery ajax with an error handler and the ASP.NET MVC action that I'm invoking throws an exception, I'd like to be able to display the message in the exception to the user. Right now I'm using: $.ajax( { ... error: function(request,status,error) { var exp = new RegExp('<title>(.*)<\/title>','i'); if (e...

How would you use ASP.NET MVC to create pages in a CMS?

In a content management system you can usually create pages on the fly eg www.website.com.au/home.aspx www.website.com.au/projects.aspx www.website.com.au/contact-us.aspx In a previous CMS that we wrote we physically created these files on disk when the user selected to create a new page in his site. We copied the new file from a bas...

How to get the ID from URL?

I am using asp.net MVC. I have edit page url like {controller}/Edit/2 so on the view page how can I get the ID from this URL? I'm gonna put a link to redirect to some page with sending above ID. EDIT Like <%=Html.ActionLink("name", "Action", "Controller", new{ ID = ? } ) %> ...

Aggregate data with LINQ and ASP.NET MVC

Suppose i have a structure Widget id name and a structure called WidgetVoteCount widgetId (FK to Widget.ID) numberOfVotes I want to display instances of Widget along with a corresponding aggregate count on my View WIDGET-TITLE WIDGET-COUNT(which is the sum of WidgetVoteCount.numberOfVotes) Blue Widget 5 Purple Widge...

Concurrency between windows and Web app C# asp.net

Hi, I am wondering if there is a best practice in regards to concurrency between asp.net and a windows app using the same db? I have a db with items their quantity, any of these items can be sold with different quantities from a website shopping cart or store location. updating the item quantity when user adds the item to their shopping ...

how do i cache FileContentResult for performance?

Presently i have the following action to return files (images, PDF's, etc) from my DB: // // GET: /FileManager/GetFile/ID [OutputCache(Duration = 600, VaryByParam = "ID")] public ActionResult GetFile(int ID) { FileService svc = new FileService(new SqlFileRepository(base.ConnectionString)); KsisOnline...

asp.net mvc multiple values to route

Hi guys, is there a way to send multiple parameters to controller as one parameter? for example, if I have route: {controller}/{action}/{languages} can parameter languages be array of strings? if it does, how to use it...how to send array to controller and how to parse it in controller method? thanks Marko ...

How do I create a strongly typed view page using ASP.NET MVC VB.NET XML Literals View Engine?

I am using the ASP.NET MVC VB.NET XML Literals View Engine created by Dmitry Robsman and described on his blog in this post. http://blogs.msdn.com/dmitryr/archive/2008/12/29/asp-net-mvc-view-engine-using-vb-net-xml-literals.aspx I would like to create strongly typed view pages using this view engine, but it doesn't seem to contain the ...

Add attributes to textbox using jquery

I am using asp.net MVC. I have control like <%= Html.TextBox("username") %> I want lost focus event to that control. So code like $(document).ready(function() { $("#username").Attributes.Add("onblur", "alert('losing focus');"); }) but it is not working, Ultimate goal is to check password & confirm password matches ...