I don't know if what i want to do is possible, but I have a JavaScript library i would like to use in the Server end of my Blazor app. Specifically in a service class.
My Blazor app has 2 environments, a Client and a Server. I am able to call my JavaScript functions on the client end using wwwroot/index.html and a blazor component, but i'm not sure how to go about doing it in the Server end. A lot of the documentation suggest providing the JavaScript function in Pages/_Host.cshtml but my project doesn't have (it has only Pages/_Layout.cshtml)
Any help is appreciated!
If you have a wwwroot/index.html and you don't have Pages/_Host.cshtml means you are using Blazor WASM project hosted by a Server project but the app code doesn't run on the server. It runs only on the browser.
If you want to use a JS library on the Server project you need to use nodejs and INodeServices. You can read this post to know how to use it : https://www.c-sharpcorner.com/article/nodeservices-where-javascript-and-net-meet-back-on-the-other-side/
INodeServices is now obsolete and there isn't replacement but you can still use it. Or you can choose to use Javascript.NodeJS instead.
Related
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.
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/
I am planning to use Angular JS + Web API together for my application.
Technologies : VS 2013, .NET 4.0, MS Server 2003.
I have my Web API & Angular JS Client on two different domains [Mandatory]. I tried achieving what i need using .NET 4.5/4.5.1 with CORS in Web API, but because MS Server 2003 does not support installation > .NET 4.0 have to give up the thought. So the solution might not be fully viable for my case.
Can someone suggest how to achieve this with the above mentioned restrictions in mind?
Any help is highly appreciated. Thanks.
One way to do this (to 'avoid' CORS that is) is to implement a solution that has a sever-side component as well as the client-side (angular). AngularJS would call the server-side (same web site, really, but a different path) that would then call the server. Thus, a client is not calling the web API directly, but the server is.
There's security concerns to be aware of, of course, but the general idea still applies: make your API calls from the server instead of client, and have the client call the server.
I am trying to figure out if ASP.net on the client side in order to support SignalR. I would rather not be reliant on asp.net if at all possible for the webclient. I haven't found anything thus far that leads me to believe that it is required, but I could be overlooking something obvious.
EDIT:
As noted by the comments my question was not correct. I am ultimately trying to find out if ASP.net is required to use SignalR. From Lain's comments below it doesn't sound like it is which is excellent!
Any information would be greatly appreciated.
No. ASP.Net isn't required on either the client or the server side.
ASP.Net is a server-side platform for .Net, so can't be used as part of a client.
There is a native C# / .Net client, but this is lightweight and does not require any http server platforms.
The server side or 'Hub' can be process self-hosted, or hooked into an existing IIS site. It does not use ASP.net directly, but can work side-by-side with an ASP.Net website.
You will need a hub running to connect to for your client.
For more information, see the SignalR project site, which has examples:
http://signalr.net/
SignalR is a libbrary build for asp.net that employs features like web sockets, long polling, forever frames. If you want to distant your self from asp.net you could implement any of these features with any server side language (directly not through signalR).
But for specifically using signalR without asp.net (although may be doable) is something I would prefer not to try or suggest. All that for the server side.
For client side simple javascript would suffice, so you do not need to use any microsoft technology there.
No ASP.NET is required for SignalR.
You'll need to have a class that Implements IHub and that class has to be in C# or VB which is obviously a language of .Net framework.
Also, the hub javascript file is outputted by signalr using c#
And any framework will be proud to announce itself platform agnostic, and signalr's home page's title itself mentions ASP.NET SignalR So defenitely you are going to need .Net.
And you need to have this RouteTable.Routes.MapConnection<MyConnection>(...); which is obviously c# in Global.asax, which is obviously executed only by a asp.net website.
And last but not the least, SignalR is implemented in C# and you need ASP.Net so that signalr executes c# in runtime.
That's a lot of reason, why you should definitely have asp.net :)
can any one please advice me, is there any possibilities to access .Net modules using php
One thing that i can suggest is
step 1 : create web service in .net which is client script enable
or create one aspx page
setp 2 : call the web service method or web page using jquery ajax or javascript ajax
by this way you can achieve things you want
Ditto pranay. .NET makes it extremely easy to create WSDL-based web services that PHP can easily communicate with. In my experience you should shy away from using DLLs if you can - doing so locks you into running your application on IIS, bit of a nasty surprise and rewrite if you ever need to switch your PHP application to a *nix based server setup.
However, depending on your needs you may not want/need to call it using jQuery. PHP has more than adequate SOAP functionality built into the core.