razor

How can Asp Net Core serve html static pages?

南笙酒味 提交于 2020-01-01 09:55:44
问题 I have recently started an Asp .Net Core app. Later I wanted to integrate it with Angular, but first I wanted a mechanism that will 'replace' cshtml with html . If I change extension from cshtml to html I get this 'InvalidOperationException: The view 'Index' was not found'. Also I tried in Startup app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); but it also didn't work. Optional is to integrating cshtml

Changing parts of view dynamically based on controller response

[亡魂溺海] 提交于 2020-01-01 09:36:10
问题 I'm looking for best approach suggestions for the below scenario: A user can choose one or more csv files to validate(Attachment 1) which on "validate" button click goes through the validation code(showing progress bar till it returns an output). A return response is either a success message or the error details for each file chosen to validate(Attachment 2) A successfully validated file can now be uploaded to azure storage with an "Upload" button. Attachment 1 Attachment 2 Now, to make

validating email address using regular expression on razor page

旧巷老猫 提交于 2020-01-01 08:37:51
问题 Hi I am using razor and trying to use regular expression to validate email address here the validation function function validateEmail(txtEmail){ var a = document.getElementById(txtEmail).value; var filter = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{0,4}$/; if(filter.test(a)){ return true; } else{ return false; } }​ but since the regular expression has a @ sign razor thinks it part of it syntax and gives me an error. Is there anyway to avoid to make sure razor disregards

Populate DropDownList in MVC 5

淺唱寂寞╮ 提交于 2020-01-01 05:46:06
问题 Here is my code for my AddNewProductViewModel using AccessorizeForLess.Data; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Web; namespace AccessorizeForLess.ViewModels { public class AddNewProductViewModel { public string Name { get; set; } [DataType(DataType.MultilineText)] public string Description { get; set; } public decimal Price { get; set; } public string AltText { get; set; } public int Quantity { get; set; } public string ImagePath { get;

ASP.NET MVC 3 faster localization?

孤人 提交于 2020-01-01 04:56:14
问题 is there any way to speed up the string localization on ASp.Net mvc3 with razor? Lest say I write on my .cshtml "Hello World", and then I want to send that "Hello world" to the resources, with an automatic Id and refactor that string to the calling the resource, with just some clicks. Something like http://resourcerefactoring.codeplex.com/ but for VS 2010 and razor. And Free! Thanks! 回答1: So I touch some few lines of the Resource Refactoring Tool and I make it work with Razor (cshtml files).

ASP.NET MVC3 bind to subclass

本小妞迷上赌 提交于 2020-01-01 04:55:12
问题 I have a superclass of type Question which has multiple subclasses (e.g. MultipleChoiceQuestion and TextQuestion ). Each of the subclasses have their own editor templates (e.g. ~/Shared/EditorTemplates/MultipleChoiceQuestion.cshtml ). What I would like to do is create a list of Question objects: class Questionnaire { List<Question> Questions; } which will really contain instances of the subclasses: Questions.Add(new MultipleChoiceQuestion()); Questions.Add(new TextQuestion()); I then pass the

MVC4 Date Picker with Default Date

让人想犯罪 __ 提交于 2020-01-01 04:43:31
问题 I am using MVC4 with the Razor view engine. My controller is as follows: public ActionResult Index() { return View(new EmployeeIndexViewModel { ToDate = DateTime.Now }); } My View Model is as follows: public class EmployeeIndexViewModel { [DataType(DataType.Date)] public DateTime ToDate { get; set; } } On my view I have a simple EditorFor() call: @Html.EditorFor(model => model.ToDate) But still get a default (masked) value in my date picker: QUESTION: How can I get today's date (from

IIS returns 404 for ASP.NET MVC3 file (.cshtml)

一世执手 提交于 2020-01-01 04:43:09
问题 I have standard ASP.NET 4 application. Inside this application there are also few razor (e.g. test.cshtml ) files. ASP.NET application works however if I point browser to /test file (without extension). IIS (static file handler) returns 404. The same application and even the standalone .cshtml files are working on local machine (with IIS7.5/Win7) and a server with (IIS7.5/Win2008R2), however it does not work the server with IIS7.0/Win2008. MVC3 is installed on both machines, app pools on both

Razor Generator: how to use view compiled in a library as the partial view for master defined in main mvc project

≡放荡痞女 提交于 2020-01-01 04:37:27
问题 We have an ASP.NET MVC 4 application with around 3000 views in it. We've decided to split this set of views into separated DLLs and compile it with RazorGenerator. We keep only main _Layout.cshtml and related files in the main MVC project. We cannot load partial views from DLL together with master view in main MVC project. Detailed description is below. What is already done: The views compile successfully into DLLs (I've confirmed that they are in the binary) The PrecompiledMvcEngine object

How can I pass HTML content to a Partial View in MVC-Razor like a “for” block

混江龙づ霸主 提交于 2020-01-01 04:17:09
问题 I'm using Chromatron theme for an admin panel in my application. There is a sidebar gadget that has HTML content and with a little CSS trick it can be shown completely different. <section class="sidebar nested"> <h2>Nested Section</h2> <p>Lorem ipsum dolor sit amet, conse ctetur adipiscing elit. Maec enas id augue ac metu aliquam.</p> <p>Sed pharetra placerat est suscipit sagittis. Phasellus <a href="#">aliquam</a> males uada blandit. Donec adipiscing sem erat.</p> </section> I want to have a