Add Forms authentication to Durandal Template project - asp.net

I want to use the Durandal SPA Template in Visual Studio 2012. Unfortunately it doesn't have Forms Authentication controllers and views etc in the template. I can add all this manually but wanted to see if anyone knew if there was a quick way via nuget or anything that will add these on for me?
Essentially I want to create a login screen before the SPA. Using an existing database which used Forms authentication before so need to keep the same.

You should be able to just install the Durandal Starter Kit from nuget on top of an existing project that includes the forms authentication bits that you need.

Related

How to login sense/net from another asp.net website?

I have a website build by asp.net, and want to embed sensenet web app into my website(maybe using iframe?), how can I handle the authentication for sensenet? Or are there any other ways to achieve this?
You have several options to achieve this, it mostly depends on your application structure, and what parts of Sense/Net do you want to use.
I recommend to give a try to Sense/Net ECM 7.0. It's in Beta stage at the moment, but you can already use the core functionality (e.g. the Content Repository, OData API, WebDav, etc...) and it's very easy to install from NuGet to an existing Asp.NET MVC project.
There is no GUI layer included at the moment, but you can use Sense/NET directly from your Asp.Net application.
If you want to use the Sense/Net WebPages Gui, there will be a package also available soon from NuGet.
If you want to keep your website separated, you can authenticate with Basic Auth, but with the next update, SN7 will support JWT authentication

can I add the Web API folders to an existing project?

Microsoft has a great tutorial here for learning how to build Web API web apps in Visual Studio 2013:
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
in it, he shows you how to include the Web API folders and references:
...is there a way to add these to a previous ASP.NET Webforms project that didnt have that checkbox selected? I'm working on an existing app and want to add Web API functionality to it.
thanks
yes -- there is a tutorial for adding Web API to an existing ASP.NET Webforms project here:
http://www.asp.net/web-api/overview/creating-web-apis/using-web-api-with-aspnet-web-forms
...it doesn't create the Models, Controllers, or App_Start folders, but i added them manually and placed my files from another stand-alone project there. once adjusting the namespaces it all operates properly.

Adding Web API to existing asp.net web forms Application

My team wants to upgrade from WCF to Web API. We have a working asp.net web form application, that we have imported to VS2012 from VS2010. So far so good.
But now as I try to make a separate Web API project, I see that there is no Web API template available. The closest thing that I can find is by creating an MVC 4 application and setting the Project Template as WebAPI. I followed this way and everything falls in perfectly. I have the working API with a sample controller that I can invoke by making calls from the browser.
The only downside to this is that, this particular method brings in its own baggage. The MVC 4 project I created has JQUERY and other libraries included, plus some other folders that I probably don't need. What I want is the Web API structure only - and not the extra baggage.
I tried finding a template using online search but the package I found does not work properly and as very poor rating.
I hope I have illustrated my problem properly. I am looking forward for some feedback now :) Thanks.
In Visual Studio 2013
Right-click on the ASP.NET Web Forms project.
Add -> Add Scaffolded Item... or New Scaffolded Item...
Under Installed/Common/MVC/Web API choose the scaffold type you wish
to use.
Follow the instructions for the scaffold template. For example, when you choose "Web API 2 Controller with read/write actions" or "Web API 2 Controller - Empty", you are prompted for a controller name
You will then need to move the recently created controller into the recently created Controllers folder.
Results
From what I can see, Visual Studio does the following:
"App_Start/WebApiConfig2.cs" is created.
Controllers folder is created.
Web.config is edited to add "handlers" element with content in "system.webServer".
The following references are added:
System.Net.Http
System.Net.Http.Formatting
System.Web.Extensions
System.Web.Http
System.Web.Http.WebHost
packages.config is updated to include:
"Microsoft.AspNet.WebApi"
"Microsoft.AspNet.WebApi.Client"
"Microsoft.AspNet.WebApi.Core"
"Microsoft.AspNet.WebApi.WebHost"
Notes
Subsequently, I recommend following the same steps, starting with right-clicking on the Controllers folder instead of the project. This will put the new controller in the Controllers folder instead of at the root level.
Readme from Visual Studio after following the above steps:
Visual Studio has added the full set of dependencies for ASP.NET Web API 2 to project 'RowersCode.Web'.
The Global.asax.cs file in the project may require additional changes to enable ASP.NET Web API.
Add the following namespace references:
using System.Web.Http;
using System.Web.Routing;
If the code does not already define an Application_Start method, add the following method:
protected void Application_Start()
{
}
Add the following lines to the beginning of the Application_Start method:
GlobalConfiguration.Configure(WebApiConfig2.Register);
After much research I have been able to come up with a solution to this problem. Let me illustrate my solution with respect to the Visual Studio Version.
VS 2012
As I mentioned in the question, there is no definite way to create the Web API project in VS2012. You are gonna have to do it by creating an MVC 4 application and setting the Project Template as WebAPI. Then once you have done this and you have your Web API functional, you can safely delete the extra baggage like the Jquery libraries and other stuff, because these things are absolutely of no use here in your project.
VS 2013
In VS2013 there is however a better approach followed to add and manage the Web API projects. Currently I am using VS2013 for the Web API and all things have fallen into place just as I wanted. Kindly see this link and you will get a better idea
http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
I hope this information will help all those new to Web API. Especially for those who want to upgrade to Web API or add Web API to existing projects.

ASP.net 4.5 / Forms Authentication

I want to set up forms authentication in my asp.net site. I have created one from a blank template in visual studio. I already have a database setup but it doesnt have any user tables. All of the reference material that I am able to find online is either for very old asp versions (which I assume things have changed) or tell you to use the visual studio templates. I want to know how to add this stuff to my current project and am hoping someone has good reference recommendations.
Thanks!
Have a look at Jon Galloway's SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates

Asp.Net Website project with 'add view' tooling

There are many posts on this, most of which suggest adding the MVC project type GUID to the .*proj file.
THe website project model doesn't have a project file though, so is there some way to get support for the add view dialog and tooling with a hybrid website / MVC project?
There is no way to achieve what you want in a WebSite (at least not currently). The Add Controller functionality is implemented as a VSPackage that gets loaded when the MVC project type GUID is detected (that's why all the other posts mention it).

Resources