Is there a way to list all current Kestrel server configuration on a running server? - asp.net-core

There are several different ways to configure a Kestrel server (JSON file, IWebHostBuilder, environment variables) but is there any way to view the entire applied configuration together? It would be nice to read the final outcome after using more than one of these configuration options.
I'm running .NET 5.0 ASP.NET Core apps in Linux Docker containers and was really hoping for something I could look at via the command line in the running container. Is it all just in memory and this is an impossible ask? I'd even take a local-only landing page or something.
I've read all documentation I can find and haven't seen this addressed.

No this isn't possible today. File a feature request on ASP.NET Core describing what you would like to see https://github.com/dotnet/aspnetcore/issues

While not quite what I was looking for, I found IConfigurationRoot.GetDebugView() which gives me the information I need. It "generates a human-readable view of the configuration showing where each value came from."
I can't use it in a shell on the web server like I initially asked, but it could be output to a page or API for debugging.

Related

How to make use of common files across projects using an IIS7 virtual directory

The scenario:
I'm very new to ASP.Net MVC programming and running into a wall constantly trying to make use of common files (.js, .css) across multiple projects.
The idea is to have these generic files in 1 location which provides for easy future updates and avoids the "copy and paste" dilemma across all the projects. I've set this folder up in IIS7 as a virtual directory in the default website with an alias "CommonFiles".
The problem:
With MVC-4 I'm trying to add the js files to a script bundle but upon running the application it's not picking the files up at all. (checked in the page source and also added a js function as a test)
Code snippet in BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/test").Include("~/CommonFiles/test.js"));
Rendering in _Layout.cshtml:
#Scripts.Render("~/bundles/test")
I've read quite a few posts (
Script Bundling in WebForms with Virtual Directories (asp webforms though), How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app, ScriptBundle not rendering scripts that are in a VirtualDirectory) but i'm afraid my lack of knowledge on MVC is limiting my path forward and really hoping to get some insight into how MVC handles IIS virtual directories and if it's even an easy possibility given the last post i've read above.
Can this be done in MVC-4 and if not what is a second best alternative in reusing common code across projects?
After reading a post by kev (Using ServerManager to create Application within Application) it put me on the right path and the issue I had is actually embarrassing.
For the sake of other devs landing on this post with a similar issue in visual studio, this is what fixed my issue:
Problem:
I make use of a separate project which contains files that are used across multiple other projects. I created a virtual folder in IIS7 referencing these files. This means if a change is needed to the common files, it's updated once and all the other projects will automatically "see" the change.
My other individual projects make use of script bundling to include files relevant only to the said project, but also to reference the common files in the virtual folder as defined in IIS.
My MVC-4 web application wasn't picking up the common files given the syntax above, in neither debug or release..
Solution:
When developing in VS2012, under the project's properties, there's a setting under the web tab where you can specify whether you want to use local IIS web server or IIS Express to test your application. IIS Express adds a random port to the site in order to test, and to allow multiple instances of sites to run (on different ports). This seems to throw the virtual directory include off in the bundling.
Choosing to use the local IIS server is closer to what the "live" environment would be in my opinion. Just un-tick the "Use IIS Express" setting.
As a side note and for more info on what the difference between the usage of IIS and IIS express is and whether it's suitable for your environment (as it was for mine) see this link:
http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx
Hope this helps someone in future and saves them the amount of time I wasted on this!

How to recognize programmatically that application is installed vs development mode?

I'm trying to get information about license info of my app and MSDN docs (http://msdn.microsoft.com/en-us/library/windows/apps/hh694065.aspx) advice to use Windows.ApplicationModel.Store.CurrentAppSimulator class for that purposes during development/testing and when submitting app to store replace that class with Windows.ApplicationModel.Store.CurrentApp.
I wonder if there is any way to check in code (javascript in my case) if app is already installed from store so my code should use proper class and I won't have to remember every time I submit update of app to store to replacing those classes properly.
As far as I know, I could not find such thing. In fact, LicenseInfo is what provides information about the store listing.
I use a config.js file to keep settings at place which change between development and production. For example - if your app talks to a service, service URL also will likely change between development and production; the service might be running at localhost for development and for production in azure environment. I keep a bool in here and change by hand.
I have not automated it fully. but it is likely possible. need to dig through the msbuild logs for the build created for the store. if there is configuration setting found, then project can have two config.dev.js and config.release.js and msbuild need to conditionally pick the right file. I haven't looked into this yet.
I think I found at solution as described here WinJS are there #DEBUG or #RELEASE directives? . Not ideal, but works for me.

Is there a decent, standalone, cross-platform webserver that will work in concert with Autorun on USB Jump Drives?

I'm trying to find a decent standalone webserver that I can load up on a jump drive.
My wife is a photographer, and I'd like to present the clients with their images on usb. When they plug it in, I'd like a web page to load up, and run some jQuery magic to show them a nice carousel of all there images.
So far, this is all fine since it can all be done client side and doesn't need a server at all.
The problem I'm facing is that I'd like some server-side code to be able to read the images out of the directory so that once the interface is built, I don't need to manually create all of the <img /> tags.
If it was primarily going to be used in a Windows environment, I'd have no problem going with IIS Express, since I'm mainly a .NET MVC developer and this would be perfect for me... However, the fact of the matter is that a large amount of our client base is also OS X users.
I did find this Java one jlHttp, and I also found this thread here on SO, but I don't think I understand enough about either one of them to accomplish what I'm looking for.
Thanks in advance for your suggestions.
I'm looking for the same thing, and the two best options I've found were Flying Ant cd web server and Stunnix. Of the two, Flying Ant is cheaper, and I've tested it with success on my project.
I found Mongoose very convenient for this exact purpose. It's crossplatform, lightweight and requires minimum configuration. You may be interested in this project that uses Mongoose to display pictures in a folder tree or FTP directory.
How about Node.js
It says it runs on Linux, OS X, and Windows.

How would I created a flexible EC2 Windows 2008 boot script?

If you look at the Linux ecosystem (especially the Ubuntu and Alestic EC2 images) there is a common technique where the VMs are pre-configured to look at the EC2 user-data and use it as a boot script. The nice thing about this approach is that you can write a boot script that further provisions your machine, allowing you to avoid making a new image every time your software that runs on the machine changes.
I want to do the same thing for Windows, but given that I'm an Mac and Linux guy, I'm a bit lost on where to start. My requirements are:
This must run on Windows Server 2008
A bootstrap script needs to start when the machine boots up, read the user-data file by pulling down the contents http://169.254.169.254/1.0/user-data
The bootstap script then needs to run the contents of that file as if it were a script
The script embedded in the user-data needs to run in such a way that it has access to the desktop environment (ie: it can launch a browser, etc).
I'm not quite sure how services work in Windows or if I need to enable auto-login, so any advice here would be appreciated. The ultimate goal is to run a Java program that launches some custom software that in turn launches a web browser (IE, Firefox, etc) and is capable of taking screenshots.
The screenshot part is interesting, because in the past when I've tried this the only way I could get something other than a black screen was to have UltraVNC or RealVNC boot up as a service, though I don't know why that helped.
I'm looking for answers to three specific questions, as well as any general advice:
Should I be focussing on a Windows service or auto-login + bat file in the "Startup" folder?
If I use a Windows service, is there anything special that I need to do to make sure desktop access and/or screenshots are available?
Do you recommend any tools for common Linux commands, like curl or wget? Last time I used Windows I used Cygwin a lot, but is there something more appropriate to use here?
I have not tried auto-login on Windows instances in EC2, but here's the support document on how to enable it.
We boot-strap our Windows instances using a custom AMI with a custom Windows 'install' service already installed. The boot-strap installer reads a URL from user-data at startup. The URL points to a ZIP file stored in S3. The installer then downloads, un-zips, and executes the actual application installer -- in our case a simple CMD fie.
This setups allows us to have one base AMI and then be able to easily overlay 15+ different application configurations (without having to rebuild the AMI). If you only have one application configuration this may be overkill for your situation.
The only trouble we ran into was having our installer service start to early -- changing the service startup mode to "Automatic Delayed" fixed that issue.
We wrote our boot-strap installer in Java, launched via YAJSW, because we're comfortable with it. If you just want a few simple Unix tools, most are available pre-compiled for Windows, for example wget.
For something completely different, you could try PsExec to configure the instance after it has booted.
You can try using RightScale's free developer account to create plain Powershell scripts and associate them with your Windows instances to run at boot time. The RightScale dashboard solves exactly the problems you are trying to solve above.
DISCLAIMER: I work for RightScale.
As for screen capture CutyCapt is a simple tool you can point at a URL and generate an image from.
Unxutils is a great solution for those looking for unix tools on Windows. It's got the wget.exe that you're looking for, however, using Powershell to download stuff is not so bad either:
$wc = new-object system.net.webclient
$wc.DownloadFile("http://stackoverflow.com","test.html")
If you can write a batch file to do your setup, then you can run it at startup of the vm by doing this:
1. Run REGEDT32.EXE.
2. Modify the following value within HKEY_CURRENT_USER:
Software\Microsoft\Windows NT\CurrentVersion\Winlogon\ParseAutoexec
1 = autoexec.bat is parsed
0 = autoexec.bat is not parsed
As an answer to #3, I would say that you can do just about anything in a batch file that you need which includes downloading from a ftp server (but not from a http server). I am really interested in this stuff and so if you have questions, try asking me.
If you use Elastic Beanstalks you can use this:
Customizing the Software on EC2 Instances Running Windows
It uses YAML formatting standards, e.g.
packages:
msi:
mysql: http://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-6.6.5.msi/from/http://cdn.mysql.com/
or
sources:
"c:/myproject/myapp": http://s3.amazonaws.com/mybucket/myobject.zip
I know this is a little bit late to help out with the original post but for anyone who is still reading this one solution is to use the http://cloudinitnet.codeplex.com/ project. The service is easily installed using a powershell script and will create a local administrator account to use while running.
The goal for this project was to replace the Cloud-Init project used in Amazon Linux and Ubuntu.

Is there a good way to wrap an existing Python based web application to require a login?

I'm in the process of installing an open-source Python based web application to an internal server here at work. The existing code is open - it doesn't require a login to view it - but one of the requirements is that users have to be approved before they can see anything.
Is there a good way (using Apache configuration files for example, but any method would be great) to wrap the application so that any access requires a login? I would like to avoid modifying the open-source code (a maintenance nightmare every time a new release comes out).
Any thoughts or suggestions?
Apache supports Authentication, Authorization and Access Control.
It is a detailed process, and summarising it here would not do it justice. I refer you to the link provided,