razor

ASP.NET MVC (Razor) vs Angular 5

一笑奈何 提交于 2020-01-23 07:22:44
问题 We are currently considering moving from ASP.NET MVC to Angular 5, mostly because it seems like the best and latest framework. However none of us seems to be able to come up with hard reasons on why Angular is better than MVC (Razor). SPA vs MPA seems like different approaches with neither really being better - just better at different things. Are there any resources/comparisons with hard benefits between the two? Update: Almost 2 years after moving to Angular 4 (currently 7) I can say that

ASP.NET MVC (Razor) vs Angular 5

孤街醉人 提交于 2020-01-23 07:22:26
问题 We are currently considering moving from ASP.NET MVC to Angular 5, mostly because it seems like the best and latest framework. However none of us seems to be able to come up with hard reasons on why Angular is better than MVC (Razor). SPA vs MPA seems like different approaches with neither really being better - just better at different things. Are there any resources/comparisons with hard benefits between the two? Update: Almost 2 years after moving to Angular 4 (currently 7) I can say that

Why I cant use Html.RenderPartial in razor helper view File in App_Code Folder?

孤者浪人 提交于 2020-01-23 05:49:04
问题 Simple Razor Helper in App_Code Folder: MyHelper.cshtml @using System.Web.Mvc @helper SimpleHelper(string inputFor){ <span>@inputFor</span> Html.RenderPartial("Partial"); } Simple View in Views/Shared Folder: MyView.cshtml <html> <head </head> <body> @WFRazorHelper.SimpleHelper("test") </body> </html> Simple Partial View in Views/Shared Folder: Partial.cshtml <h1>Me is Partial</h1> Compiler throws an Error: CS1061: 'System.Web.WebPages.Html.HtmlHelper' enthält keine Definition für

Correct way to mutate a component property in blazor

眉间皱痕 提交于 2020-01-23 02:43:11
问题 I have two components, Child.razor and Parent.razor . The Child.razor HTML: <input type="text" value="@Text" /> The Child.razor C#: [Parameter] public string Text { get; set; } And the Parent.razor HTML: <Child @ref="child_1" /> <Child @ref="child_2" /> <Child @ref="child_3" /> Parent.razor C#: Child child_1; Child child_2; Child child_3; void SetText(Child item, string text) { item.Text = text; } I get a warning on the item.Text = text : Warning BL0005: Component parameter 'Text' should not

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

Web api authentication and MVC 4

≡放荡痞女 提交于 2020-01-22 23:09:08
问题 I have the following solution: Web api project. MVC 4 project. I need to authenticate user by sending its credentials using a JSON request (https is a must). is it a good approach ? and how can i authenticate the user on both web api and MVC . 回答1: is it a good approach ? Yeah, why not. and how can i authenticate the user on both web api and MVC . If the Web API requires authentication you could use the same Forms Authentication as the MVC application. So you could configure Forms

Web api authentication and MVC 4

被刻印的时光 ゝ 提交于 2020-01-22 23:09:05
问题 I have the following solution: Web api project. MVC 4 project. I need to authenticate user by sending its credentials using a JSON request (https is a must). is it a good approach ? and how can i authenticate the user on both web api and MVC . 回答1: is it a good approach ? Yeah, why not. and how can i authenticate the user on both web api and MVC . If the Web API requires authentication you could use the same Forms Authentication as the MVC application. So you could configure Forms

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:

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: