Angular 2/4/5 Inside ASP.NET WebForm application - webforms

Right now we have a Asp.Net web form application which is hosted in IIS.
How can I add my angular-5 script files inside the existing Application in IIS?
And if so, How my angular routing will work?
NOTE: Here I don't want to host my Angular project separately inside the IIS.
Let me know in case the question is not understandable fully. I can give the example.
Thanks in advance.

I know it might be a bit late, but I recently faced a similar problem, and I wanted to share it in case anyone else stumbles with the same problem. Even if it would have be preferable to host it in some other way, we needed to integrate a new Angular application with an existing WebForms one.
To give the control of the router to angular, declare the next function in Global.asax
Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.MapPageRoute("MyRouteName", "MyAppPath/{*path}", "~/MyAppAspx.aspx")
routes.MapPageRoute("MyRouteName2", "MyAppPath2/{*path}", "~/MyAppAspx2.aspx")
'And so on
End Sub
This will make webforms redirect all requests to "myhost/MyAppPath/" to the provided aspx, so that angular can take care of the routing.
Then you must just create the required aspx and provide there the needed scripts in the order they appear in the generated index.html.

Related

Ajax not working with laravel project deployment

I know this might be a broad question but i recently finished developing a laravel 5.6 app. I deployed it to a free hosting service (000webhosting) because i wanted the client to be able to preview it remotely from where they are without having to sign up for domains and hosting accounts and all that jazz.
I uploaded it by zipping my project folder and putting it in the directory of the cpanel. I put all the public files (including .htaccess) into the public_html folder and put the rest of the project into the parent directory.
Long story short, everything works fine except for ajax. Other non-ajax CRUD is functional but nothing ajax related works. It all produces 404 errors. The other non-ajax functionalities are in the same controller as the ajax methods! so i know the project is talking to itself. I have jquery library linked to on the hosted google libraries page. Is there some sort of convention that i'm missing that is limiting this functionality? do some web servers block ajax requests? It's working perfectly in my localhost wamp environment. What could i possibly look into to resolve this ajax discrepancy? If it comes to it, i'll pay for hosting, but i just want to make sure this isn't a consistent topic with many host providers where ajax needs to be specially configured or something.
github.com/maximus1127/drive ....this is the github repo. the file in question is drive/resources/views/auditor_pages/application_review.blade.php.
To login the browser, go to https://makemedrive.000webhostapp.com/ login with "aa#aa.com" pw "password". Click the instructors tab on the left, then instructor application, then view details. The "save notes", "background check/received" buttons are all the ajax features of this page and none of them work. They all produce 404 errors. Please help!
Thanks in advance!

Is JSP necessary for Angular2 security for different roles

I am build an application using Angular2 as front end framework and spring boot as backend framework.
One of the seniors in my team insisted on using JSP as templates for my components in order to avoid rendering any unauthorized views.
Is that really nessecary? I saw many applications which are implemented using angular or other front end frameworks but it did not render the templates in backend, is it a good practice? isn't authenticating the requests is enough?
Also would not that be a problem for performance?
From my point of view I think JSP will prevent us from using the potentials of Angular, any help or documentation on that subject would be much appreciated.
Short: No, JSP is not necessary.
Long: One has to realize where which part runs. JSP on the server, Angular in the browser. I assume your senior colleague is concerned about displaying unauthorized data - but that is not the concern of Angular. Angular is basically just the View, and, perhaps, Controller. But it has to get the data from the server - which is usually done over some REST service. And it is the duty of that service to serve only data the user is allowed to view. So you can implement your View/Controller part in Angular, putting all the views (event the restricted ones) in, and then implement proper security into your server-side data service.
No, it's not necessary to use JSP in Angular 2.
It's correct that JSP allows you to protect the template itself from unauthorized access, but in our case it's not really a bad thing to happen from the security point of view, as access to the template without the data itself is not something dangerous; The data of course must be protected w/ your own security/authentication to prevent unwanted access to it.

MVC 3 Content and Relative Path is not working when deployed to IIS 7.5

I am developing a MVC 3 Web Application and just tried to deploy it on IIS 7.5
The page is shown, but all the images as well as url path is not working at all.
I search through a lot of sources and found out that it seems to be compulsory for a MVC application to have all path being enclosed in either:
#Url.Action
#Url.Content
#Html.Action
and so on. So I tend to change all my relative path by using those valid method.
I understand it should be a correct way to use all those valid mvc helpers, but I am just a beginner and this is my first web application. My question is:
Is it possible to use any method to "resolve" the relative path so that it can be found even after deployed?
Really need help here... thank you very much....
You are not correct that you need to use those helpers for all URLs. There is nothing to prevent you from outputting URLs 'manually', as literals, or as you have done above.
Something wonky has happened with the paths of the files on your server upon deployment, most likely.

ASP.Net MVC3 user authentication tutorials

I'm currently working as a developer on a website, and it's more or less my first time doing any sort of web development. We're currently at a stage that we need to do user authentication, but I have absolutely no idea how I can accomplish this.
To that end I've tried to do some googling and searching on SO, but my google-fu is currently failing me.
Are there any tutorials that can take me from knowing nothing about authentication, to being to set up some secure authentication on my website?
We're developing this under MVC3 with Razor view engine, if it helps at all.
I would say here is a good starting point. The fact that it's MVC3 isn't really going to change anything (i.e., the Razor view engine doesn't change anything about authentication in MVC)
Take a look at the ASP.NET MVC Music Store example application, specifically Part 7.
what ErOx posted + here is sample implementation of custom MembershipProvider

IIS7 MVC deploy - 404 not found on some actions

Once deployed parts of my web-application stop working. Index-es on each controller do work, and one form posting via Ajax, Login works too. Other then that yields 404. I understand that nothing particular should be done in integrated mode.
I don't know how to proceed with troubleshooting.
Some info:
App is using default app pool set to integrated mode.
WebApp is done in net framework 3.5.
I use default routing model.
OS is Windows Server 2008.
IIS 7
Any help is appreciated. Thx.
EDIT:
I determined that only actions that accept ID parameter don't work. On the contrary, when I add dummy id method in Home controller of default MVC app it works.
EDIT 2:
I found the problem. Links on few pages of the site didn't use ActionLink helper. It was harder to see because of the Ajax invoking. So, never hardcode links to the actions on the site, even temporary.
Please go through this link for details on deploying MVC application with IIS 7 integrated mode.
http://www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs

Resources