Using pub serve with ASP.NET Core backend - dart

I'm using Dart to build JS applications that are loaded on web pages hosted from an ASP.NET Core application, and I'm trying to establish a development workflow with either pub serve or potentially pub build that allows for debugging. I've seen some related posts, but I'm still stuck. This is what I've tried:
I used pub build with dart2js and the --mode=debug flag set to generate dart sources and a sourceMap, and then used Chrome to load and debug the web pages. The problem here, apart from long compile times, is the sourceMaps don't seem to work well for the debugging. Lines in the .dart files are often unavailable for debugging, and stepping over function calls doesn't work well, instead diving into framework code. I'm also unable to see values reported reliably.
I used pub get with the --packages-dir flag to copy in dependencies and then loaded the web pages with Dartium hosted by the IIS Express server. This loads pages fine and lets me develop, but I was unable to get breakpoints working at all in Dartium unless I used the debugger() statement directly in my code. I'm also concerned about this approach in general because Dartium is no longer being updated and the Dart team's plan is to move away from it.
As an offshoot of #2, I also tried simply changing my script tag URLs in my ASP.NET pages to point to the resources on the pub serve dev server. This is blocked because pub serve apparently only serves on http, and the ASP.NET application is hosted via HTTPS locally. I tried to change the backend to load on HTTP, but now I'm running into issues with authentication/authorization not working in my .NET app. Also, I had hoped to be able to use dartdevc with this approach, but that gave me 404 errors with requirejs, I think because it was trying to load it from the IIS Express server instead of pub serve (I'm really not sure about that).
I've found some mentions in other StackOverflow posts of setting up some sort of proxying behavior in order to have a backend server request resources from pub serve, but I have no idea how this might be done or if it applies to this situation. I can't find any information.
What strategies are people using for this, and is there a best-practice in mind going forward with Dart 2.0 and dartdevc?

Related

Swashbuckle won't load resources

I have a .NET MVC application that includes a web service.
I have added Swashbuckle to the web service project and on my local machine everything works fine.
When I move the code to our TEST environment I begin to get 404 errors randomly for the various javascript and CSS libraries.
Sometimes the swagger/ui/index page itself throws a 404. Sometimes everything loads.
I've thought about downloading all of these files and placing them in my project for Swagger to use, but based on what I've read, and the way my local environment works, it doesn't seem like that's the way swashbuckle is designed to work, so I'm at a loss.
I have very limited access to the TEST environment so any server configuration will be an issue. My hope is that swagger.config file can be updated to make everything play nice.
I discovered that my TFS build server was NOT overwriting the previous build which led to differences between my load balanced servers and files that were not being updated with changes as I tried to get Swashbuckle to work.

ReactJS.net on Azure

I'm hoping I'm able to get some help out there with people with more experience on ReactJS than me. I'm using MVC 5 with ReactJS (using ReactJS.net to take care of the translation from JSX to js) and I was able to some stuff done that works pretty well. Testing the my code on my local pc works fine for debugging, but once I publish it to Azure for testing I get this error:
GET http://mywebsite.azurewebsites.net/Scripts/jsx/FriendSelect.jsx?_=1429662139230 404 (Not Found)
This is usually the error I get when the jsx file doesn't get converted to js successfully. Does anyone know the steps I need to take to get ReactJS.net to work properly on Azure?
I don't understand why you need to use anything react.net etc...? React comes with a JSXTransformer file which transforms your JSX to JS while you're in the process of developing your site. Compiled and minified JS code should be used in production once you no longer need JSX. Tools like Gulp can assist with automatically minifying your code for you.
Whether the site is Azure, Linux Ubuntu or anything else it shouldn't matter.

Dart best practices for develop and production

Sorry if this is a noop question, but I'm pretty new to Dart.
I wonder if someone has good links or ideas for best practices for develop and debug a Dart application in a node.js environment. I can start a standalone Dart app and call a rest api using absolute url, but I think the Dart app should be served using node.js and the urls should be relative. In production we also need to serve the js compiled app. Do you know how to build a good development environment, near to production?
You can create a launch configuration in DartEditor to be able to use the debugger with another web server.
https://code.google.com/p/dart/issues/detail?id=3748 (sorry couldn't find a better ressource)
The Dartium built in debugger (Chrome developer tools) works pretty well too with Dart.
You will loose some features like transformers as pub serve uses it though.
I guess the best for development is to set Access-Control-Allow-Origin header in your node.js server and develop with the web server built in in DartEditor (dart: debugging client/server communication for dart client and existing rest api?).
For testing and bug-fixing in an environment similar to the deployment environment use the configuration described above.
Dart is just like static files for the server. You don't loose much when you don't use node.js for serving Dart.

Precompile during publish for Azure Web Services

We are using Azure Web Services (not Web-sites) and run ASP.Net MVC 5.1 application inside it.
When I publish web-sites through Web-deploy, I have an option to "Precompile during publishing":
When I publish to Azure Web Services, I can't find this option anywhere. Any pointers?
The idea is to pre-compile views, so first hit to a view would not be time-penalised by compiling on the fly.
I've looked on Razor Generator but it does not suit our needs. I've seen few other options, but compiling views at publishing stage makes the most sense for our case.
UPD:
Just for my reference, I've tried what David Ebbo suggested and it did not work.
Calling compiler %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe -m /LM/W3SVC/1273337584/ROOT from command line on the Azure server seems to cause compilation. The Temporary ASP.Net root directory contains one directory this increases in-size and number of files contained within. The site then restarts after compilation. First page open performance then seems much better.
If I run this within a startup script it doesn't work as the site isn't avaible. I guess IIS hasn't started up. Looking at doing something like this Azure: How to execute a startup task delayed?
The site ID doesn't seem to change for different deployments. I guess could get the site id out of IIS and then use that it if it does.
So looks like that does it. Is there are more elegant way? Don't understand why compiling and deploying view files is such a chore.

How to publish an ASP.NET MVC website

I've a site that I'd like to publish to a co-located live server. I'm finding this simple task quite hard.
My problems begin with the Web Deploy tool (1.1) giving me a 401 Unauthorized as the adminstrator because port :8172 comes up in the errors and this port is blocked - but the documentation says "The default ListenURL is http://+:80/MsDeployAgentService"!
I'm loathe to open another port and I've little patience these days so I thought bu66er it, I'll create a Web Deploy package and import it into IIS on the server over RDP.
I notice first that Visual Studio doesn't use a dialog box to gather settings, or use my Publish profiles but seems to use a tab in the project properties, although I think these are ignored when importing the package anyway?
I'm now sitting in the import wizard with Application Path and Connection String. I've cleared the conn string as I think this is for some ASP stuff I don't use but when I enter nothing in the Application Path, the wizard barks at me saying that basically I'm a weirdo because most people publish to folders beneath the root site.
Now, I want my site to be site.com/Home/About and not site.com/subfolder/Home/About and I think being an MVC routed site that a subfolder will introduce other headaches. Should I go ahead and use the root?
Finally, I also want to publish a web service to www.site.com/services/soap which I think IIS can handle.
While typing this question, Amazon have delivered my IIS 7 Resource Kit, and I've been scouring the internet but actually I'm getting more confused.
Comment here seems to show consensus opinion that Publish isn't for production sites and that real men roll their own.
ASP.NET website 'Publish' vs Web Deployment Project
...I guess this was pre- Web Deployment Tool era?
I'm going to experiment on a spare box for now but any assistance is welcome.
Luke
UPDATE
The site was imported (to the root) manually with Web Deploy and it worked. If you get the error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' " its because your app pool is 4.0 and should be 2.0.
If you are using VS 2010, may I recommend Scott Hanselman's Web Debloyment Made Awesome?
http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx
Even if you are using VS2008, there are nice concepts there that will probably help.
I've experienced the same frustration and trouble with this as well. Coming from a Java web background where we can package everything as a single WAR and toss it on the server, the deployment process with ASP.NET seems archaic.
I currently have a python script that uses FTP to transfer the needed files to my test instance on the remote server. I have another python script that transfers those files to my live site. These scripts are smart enough to take care of differences between some of the configuration files etc..
I've found it much easier than trying to setup permissions or using the Microsoft deploy tools.
Hi you can use filezilla software to upload

Resources