Web helpers for MVC 5? - html-helper

is there any documentation for Microsoft.AspNet.WebHelpers for ASP.NET MVC 5?
I'm trying to use FileUpload helper and run out of ideas..
#using Microsoft.AspNet.WebHelpers
tried to put this line on top of my View and few other variations...

I never find documentation for all the helpers. There is no helper for the file upload.
Use and don't forget to use POST and set enctype = "multipart/form-data"

You can use Microsoft.Web.Helpers.

Related

Can I serve a static html page from mvc

I would like to be abel to run my angularjs app from the app directory from VS code without using VS2015 and without running iis express. This will make it possible to create new UI very fast specially combined with mocking the service layer.
It's a mvc5 + webapi2 application.
So I need to run /app/index.html from mvc. The index.html is a full html page not an angular template.
Create an action method that returns perticular HTML file. You can return File from controller action. have a look:
public ActionResult Index()
{
var result = new FilePathResult("~/Html/index.htm", "text/html");
return result;
}
Also check this Class: FileResult
Hope this helps!
You can simply call:
return Redirect("~/path/to/.html");
2 ways of doing so:
i. Simple replace the original index.html to your new index.html, all other libraries please place in side the corresponding folder.
ii. in web.config, you may change the maproute properties, you can map your view as default or add new map route.
Thank you.

Asp.Net MVC and AngularJS in same View

I´d like to know if exists a better way to render a view like this:
For the first load I need bring data from Controller like usual but after apply a filter in same page I need to start use AngularJS and never more uses Razor.
Is there a way to do that ?
Thanks for all.
Yes. you can do that.
Basically, you'd need to add the line below in your view. After you do that, the json is going to be available to the DOM / javascript and angular can take it from there. Hope this help
var json = '#Html.Raw(Model.MyJsonStringForMyCoolAngularJsApp)';
There are multiple ways to implement ASP.Net MVC with AngularJs.
I personally like Mini SPA (Silos). You can watch Miguel A Castro's video here.
You can also download the source at his website.
What it does is when a request comes in, it goes to ASP.Net MVC Route first. Then, Angular Route takes over the rest. It is a very slick design.
FYI: I also use Angular.Net Helpers to generate strongly typed views.
You could use WebAPI project in visual studio to exchange data between frontend and backend. It would go stateless, so to secure the data, you could use a mechanism like JWT.
The frontend would exchange JSONS from/to the backend using REST apis.
Yes. You can make angular views and exchange data using $http.get(/controller/method/). You can also configure routing using ngRoute.

Symfony 1.4 and angularJS

As mentionned in the title I want to use angularJS with Symfony1.4.
Is that possible? and How to integrate this framework with Symfony1.4?
Of course you can.
If you are familiar with AngularJS you should now that the important things to be considered is to import correctly the script files, and to declare correctly your app and controller.
The same has to be done in Symfony, importing scripts and declaring Angular app.
I'm actually using it, and it works great.
you dont need integrate Angular with Symfony because Angular is a Javascript framework (client) and Symfony its a PHP Framework (Server). simply you can make a API with symfony a simple static entry point for start the angular application and use the API from the Angular App

import Only CakePHP Html Helpers in Custom MVC project

I have an unusual task at hand, I just need to import a specific portion of CakePHP framework in my custom MVC project, i.e HTML helpers.
Can anyone tell me what code libraries from CakePHP do I need to transfer into my project , to do this.
Please note I need only HTML helpers from the CakePHP framework.
Thanks.
Just go to the CakePHP Github repository Helper directory and download them: https://github.com/cakephp/cakephp/tree/master/lib/Cake/View/Helper

Integrate js helper from cakephp 1.3.7 to cakephp 1.2.5

I am working on a project based on cakePHP 1.2.5. Now I need to use new JS helper defined in cakePHP 1.3.7.
I want to use some methods of JS helper like $this->Js->buffer("some code"),
$this->Js->writeBuffer()...
Is it possible to include this JS helper only to cakePHP 1.2.5? and How?
Thanks
I don't think you can because the basic way of calling the class has changed. In 1.2.5 the helper classes were not attached to the $this object in your view.
I think the better question would be to see if you can upgrade from 1.2 to 1.3. What are the requirements keeping you from upgrading, if any.
I would update your project to the current version of cakephp. A lot of bugs were fixed and other things were optimized.
But you can use the normal php or javascript functions...or build your own methods to solve your problem...
You could try to copy the JsHelper and its dependencies (HtmlHelper, FormHelper, and the engine helper for the Javascript framework you use) to the helpers folder of your application, though I don't know whether this will work...
However, even if this should work it is a hack, and I would consider to upgrade to CakePHP 1.3.x or to write your own helper providing the desired functionality.

Resources