What does "weather forecasts" mean? - c#

When I study the RazorPage documentation, I read the paragraph below:
In the terminal window, copy and paste the following command
dotnet new webapp -f net6.0
This command creates the files for a basic web
API project, along with a C# project file named RazorPagesPizza.csproj
that will return a list of weather forecasts.
So what does "weather forecasts" really refer to?

I suspect it's a typo/copypasta error on the part of the person who wrote the docs, importing content from documentation about a different different kind of project.
Quite a few of the Microsoft example app templates use a weather forecast to demonstrate data that might be shuttled between client and server. For example if you do dotnet new blazorserver -f net6.0 you'll end up with a Blazor Server app that has a WeatherForecast.cs and related service in its Data directory
So what does "weather forecasts" really refer to?
In the webapp template; nothing - the code doesn't really do much other than display a nav menu sidebar and index page.
If you're looking to get into web dev you might want to skip the ASP.NET webapp one, because it's fairly old tech now. The modern web development trend is for a javascript application that runs in the browser, fetches small amounts of data from a back end API and manipulates the active html document to make it look like things are happening, rather than sending massive blocks of HTML between server and client and having the browser replace the active page with another one (which is what this one does).
If javascript doesn't float your boat, take a look at Blazor; it effectively works like the javascript-plus-light-communication-with-backend I mentioned, but it lets you write all your page changes with C# alone. In a Blazor server app the server maintains knowledge of the HTML the client needs and sends small chunks of it which are patched into the active document. In a Blazor Web App a small .net runtime is sent to the client so the C# runs in the browser and formulates the HTML that is patched into the document the user sees

Related

C# WPF, and data exchange with the browser

I've a C# WPF application developed in VS 2015, and I want the browser to read some data from it. Just a short string. I can save it in a text file, or in a variable but it should be visible to the browser (using JS I suppose). For instance using file:/// doesn't work if the original page is hosted online - as in my case (different source conflict). This should work in Opera and FFox, but looking at their extensions, it seems you can only develop with front-end technologies, which are not enough in my case since I use WPF to look into Win OS, and then I need to share the result with the browser.
I suspect it's possible, and no , it's not to write a malicious piece of code. For instance I can read the details of the graphic card for diagnostic purposes.
Please help, many thanks.
Browsers run in a security sandbox which is intended to stop them reading or writing files to the file system.
You could write to the user's appdata. There are various javascript frameworks which persist data to there so they can provide offline or static data.
I don't think that is a good plan though.
I suggest your first candidate would be a cookie.
Quick google on how to do that, I find:
How to create cookie in c#.net windows application?
From a web page you can use the content of a cookie dynamically. So you could change what you see in the web page after it's up and running from some process in your wpf app and do a counter or whatever.
I've not used this with windows apps and a browser but I have with a web app and Silverlight. I'm afraid I don't have that code to hand though.

Aspx Support PWA or Not

Are there any way to do a project using pwa concept in ASPX page? I am using HTML with PWA, it was working fine but I moved into the ASP .NET. It doesn't work anymore and the JSON file is not loaded.
You will maybe found this SO post useful.
After testing, i was successful at implementing the functionality by
adding the serviceworker and manifest to a ASP.NET MVC application.
Since the view (HTML) gets rendered in the backend, it's only possible
to cache an static version of your web application. So preferable you
should use angular etc to generate your HTML.
A progressive web app works on IIS and apache web server.
progressive web app is a general concept. It has nothing to do with your web server. Please give more details about your code architecture etc
you can also use swtoolbox plugin for handing client side caching
mybe your problem is client-side caching. however PWA concepts are as follows, neither of them has nothing to do with web server type
Progressive - Works for every user regardless of their browser
Responsive - The app works on any form factor whether it's desktop, mobile, or tablet.
Connectivity-independent - Allows the user to use the web app even if it's offline.
Native Look-and-feel - Acts and feels like a native application, but is strictly web-based.
Safe - Always served up to the client through HTTPS.
Discoverable - Even though it's an "application," it can be indexed into a search engine.
Re-engageable - Allows re-engagement through features like push notifications.
Zero-Deploy hassle - Allows users to add the web app onto their home screen without the issues with app stores.
Link-friendly - Allows you to reshare using a Url.
Yes finally I able to accomplish this. PWA now works not only on ASP.NET webform but On any framework.
https://github.com/cpbenipal/PWA_Aspx

Creating a server and site with ASP.NET

following my previous post about my game server, I've decided that I want to create a web-based server, and not a WPF one.
Currently, the server is a console application. I run the server, it has a TcpListener, and I interact with TcpClients, and the only real console-y thing I have, is a bunch of Console.WriteLines that I intend to get rid of. The server itself is part of a class library, which contains all the server logic, so that it'll be easy to wrap it in whatever platform I need.
Say I have a library with all my server-side logic, and I want the GUI of the server to be a web client, while still having a server that runs in the background and keeps the game running - How do I do that with ASP.NET?
Since all my code is C#, it's natural that I would pick ASP.NET, and use MVC with Razor, allowing me to use my original classes as data in the website.
I can handle the website part of the ASP.NET, but what I need advice with is how I create a server that acts like my previous one (runs in the background, has some sort of GUI, for input, commands and etc), and also has a website as the GUI.
Thanks in advance!
for reference, all my ConsoleApplication code is here, showing just how little the platform that runs the server has to do.
And regardless, this is the link to my game code, if anyone is interested. I'm always interested in opinions and constructive criticism!
This is an article about self hosting webapi and static files in a console application using Owin, no support for MVC. Asp.Net Core has a similar work flow (though it's not called Owin anymore), and MVC is available. Asp.Net Core apps are actually self hosted in a console application using Kestrel. When you host asp.net core in IIS all IIS does is act as a proxy.

Best way/solution to display json data from a local winform .net app on angularJS web dashboard applicaiton

can u please help me out with the best solution how to do this?
I have a windows form application, which is continuously doing something. (making screenshots and generating data) This app is running locally.
So I dont want to use teamviewer from office just to see what my application is doing. I want to create an AngularJS Web Dashboard application (load it on a webhost) and display this winform data (in form of charts,..), so that I can access from everywere.
What is the best solution for this?
I have experience with AngularJS and parsing JSON-Files from a webserver.
I preffer creating/serialize a json file (each second) from my winform app and load it somewhere on webhost and then access this json file with http.get from my AngularJS application.
Is this a possible solution? Any suggestions?
Thanks!
I agree with making a Angular web app (although you don't need angular for this, you can use jquery to make a simple ajax call, seems like it would be quicker to add the jquery reference than to setup the angular scaffolding just for one or two ajax calls) to call a web request where the winforms app stores the data.
Ex. you can create a web request (or directory save) in winforms app to perform the 'snipping tool' action described here: C# snipping tool service and send the data to somewhere to store it. If the snipping tool doesn't work then probably use an export of the chart or data you are capturing. Then the web app can query that directory to retrieve (ajax/http get) whichever data you need.
I would advise clean up on that directory as it could become quite big if you are saving to it every few seconds or so.

Running Web Application Locally (Offline) & without IIS

I'm trying to understand if there is a way to make a web application run on the local computer(browser) without IIS.
My main objective is to transform my web application (that is on the internet) to a software that runs on the local computer without using the internet and without IIS.
My idea is to distributed my webapp between my colleagues and not forcing them to work online and not needing an internet connection.
I have a MVC web app with 3 pages and a couple of methods on the server side.
The idea of the application is to get proprieties from a form that I implemented on one of the pages of my web application and transform the proprieties on the client side to JSON and send it to the server, the server will generate XML file according to the JSON object and let the client download the XML file that were generated.
The flow of it:
1.The Client fill the form in my site.
2.The form become JSON object on the client side.
3.The JSON object that stored the properties of the form(filled by the client) is send to the server.
4.The server get the JSON object and generated XML document from it.
5.The client download the generated XML file.
Very simple web application.
I know that I can run HTML page by clicking it and the page will display on the browser but I need the server side to be working too to carry out actions.
So my question is : How can I make my web application run without internet ?
With the constrains:
No IIS required.
Working with .NET 4.0. (OWIN 2.0 - Not good)
No internet require.
No installation required to the computer ill pass this web app.
The server side code wont be expose when I send this application to my friends.
I read a couple of articles about OWIN, SingalR, Cassini and WCF but its all very vague...
If someone could provide me with a guide lines it will be very helpful.
Thanks a lot.
You can definitely self host a .NET web application using OWIN. Unfortunately documentation and information about it is vague and confusing at best. The fact that you're using MVC makes it somewhat easier as you may be able to directly use the self-host packages from Nuget for self hosting Web API. There may be similar packages for MVC.
I don't have recent experience but a Nuget search for "MVC Self Host" should yield some results.
Below is a link with an example. But the term you are looking for is definitely "self host". It can be done via a console window or (more complex) a windows service. It will likely use some form of OWIN but you can probably find some startup code to copy and paste into your project, usually in the form of a Startup.cs file.
http://www.c-sharpcorner.com/UploadFile/4b0136/working-with-owin-hosting-and-self-hosting-in-Asp-Net/

Categories

Resources