asp.net-mvc-3

ASP MVC4 and Azure - Bundling and Minification stopped working for me when I publish to Azure

為{幸葍}努か 提交于 2020-01-23 02:18:10
问题 In the Windows Azure Publish Settings I have selected: Environment: Production Build Configuration: Release In my Web.Release.config I have: <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> I had bundling working before and I made no code changes that I know of. However now when I publish to the cloud and view web pages it seems there is no bundling at all. All the javascript and CSS are downloaded one by one. Is there something I am missing? This used to work and now it

Is it possible to reuse partial views on multiple projects in ASP.NET MVC?

江枫思渺然 提交于 2020-01-23 01:12:09
问题 I know ASP.NET MVC 3 doesn't support area reuse, which would be very handy for, say, user admin areas of web applications, but how about partial views? Say I have Pager "control" as a Razor (or WebFormViewEngine , it doesn't matter) partial view which I can easily reuse inside my MVC application. Is it possible to reuse it in multiple MVC applications other than by creating a partial view in the new application and copy-pasting the code? 回答1: There is nothing buit-in the framework that allows

ASP.NET MVC - Update Pre-compiled Razor View file Live in Production

梦想的初衷 提交于 2020-01-22 22:56:18
问题 I was wondering if the following is possible : Precompile the Razor views with our MVC app by turning on the project setting in visual studio. Deploy the app to production. Then at a later stage, update the views by overwriting the existing *.cshtml files in production without recycling the app pool or re-compiling the project and re-deploying the build.? 回答1: Yes you can do this. The view engine will recompile all the files in each directory into a separate DLL into a file like this C:

ASP.NET MVC: Downloading an excel file

两盒软妹~` 提交于 2020-01-22 20:06:40
问题 I'm downloading an excel file within C# action method the reutrns a FileResult, like this: return File(bindata, "application/octet-stream", "mytestfile.xls"); When I manually navigate to the URL that corresponds with the above method, then I get the rendered out representation of the file. The file will not download with a Save As -dialog. Is there a way to force the download to happen through Save As -dialog? -pom- 回答1: I have a feeling you are getting this behavior because of the media type

ASP.NET MVC: Downloading an excel file

旧城冷巷雨未停 提交于 2020-01-22 20:06:05
问题 I'm downloading an excel file within C# action method the reutrns a FileResult, like this: return File(bindata, "application/octet-stream", "mytestfile.xls"); When I manually navigate to the URL that corresponds with the above method, then I get the rendered out representation of the file. The file will not download with a Save As -dialog. Is there a way to force the download to happen through Save As -dialog? -pom- 回答1: I have a feeling you are getting this behavior because of the media type

How to add parameters to a @Url.Action() call from JavaScript on click

扶醉桌前 提交于 2020-01-22 19:39:47
问题 I have a link that when clicked needs to call a controller action with certain data which must be retrieved via JavaScript. The action will be returning a FileStreamResult. I looked at @Url.Action but I couldn't figure out how (or even if) I could pass value dictionary stuff which had to be retrieved via JS. So then I went with a $.post from a click handler. The problem I'm having is that I'm not sure what to do in my success: function() to return the file stream result to the user. Or even

Outputting Json with the Razor view engine

心已入冬 提交于 2020-01-22 18:51:14
问题 I've got a dictionary<string,string> as part of my view model. What I'm trying to do is cycle this object and output it as a json object. My reason for this is so I can localise my client script files correctly. The output for this needs to look something like var clientStrings = {"test":"yay","goodBye":"Nah"}; Any ideas how to achieve this correctly. Thanks in advance. 回答1: Considering you are on mvc 3 you'll have access to JavaScriptSerializer. You should be able to do the following:

Razor mvc3 + jquery + UrlAction + PartialViews

百般思念 提交于 2020-01-22 15:25:08
问题 I have a question about jQuery + Razor.. I want to build a javascript variable using razor with @Url.Action and the html attributes will be values of inputs. Like this: var d1 = $('#d1').val(); var d2 = $('#d2').val(); var url = "@Url.Action("Links", "PartialAccount", new { beginDate = "d1", endDate = "d2" })" $("#links").fadeOut("slow").load(url).fadeIn("slow"); How can I do this? Is it the same that below? var url = "/PartialAccount/Links/?beginDate=" + d1 + "&endDate=" + d2; 回答1: You

MVC 3 specifying validation trigger for Remote validation [duplicate]

不羁岁月 提交于 2020-01-22 15:07:04
问题 This question already has answers here : ASP.net MVC 3 jQuery Validation; Disable Unobtrusive OnKeyUp? (6 answers) Closed 6 years ago . I have implemented remote validation using MVC 3 unobtrusive validation as follows The model public class MyViewModel { [Remote("ValidateAction", "Validation")] public string Text { get; set; } } The Controller public partial class ValidationController : Controller { public virtual JsonResult ValidationAction(string aTextToValidate) { if(aTextToValidate == /*

How to render a model property of string type as checkbox in ASP.NET MVC

╄→гoц情女王★ 提交于 2020-01-22 13:13:05
问题 I want to display a string type as checkbox on MVC view, but returns it as string type on HTTP post. The problem is that it returns false on HTTP Post. Below is my code: View: @model List<Car> foreach(var car in Model){ bool isFourWheel = false; if(bool.TryParse(car.IsFourWheel, out isFourWheel){ @Html.CheckBox("IsFourWheel", isFourWheel); //need to be rendered as checkbox, but returns string type on HTTP POST } } Model: public class Car { public string IsFourWheel { get; set; } //bad naming,