How to convert make proper React Link from source html code? - c#

I have React TypeScript application (ASP.NET MVC Core 2.0 Server side).
Users can write html messages and post them on site.
On server side I sanitize and repair posted html to render on client side.
But if there is local links like link, targeted my React navigation components, if user clicks this link, whole site is refreshed(rerendered), but I need to act as React Link just to handle link inside React, not to rerender whole site.
How can I convert A link to React Link (on server and/or on client)?
May be there is something like PrepairLink function on client?

Related

Is Blazer server SSR and SPA?

I heard that the Blazer server is SSR(server-side rendering).
By the way, I know that the Blazer server is a single page apps (SPA).
Is the Blazer server both SSR and SPA?
Then, does the Blazer server first receive data through SSR method and then receive data through CSR method to implement the SPA?
It depends on your definitions.
Blazor Server is Server Side Rendering. All the work goes on the server. It builds an html page which it passes to the client. JS client takes over, refreshes the page and then sends requests and gets bits of the page back from the server to render when they change. All the heavy lifting takes place on the server.
Blazor WASM is Client Side Rendering. The client gets a load of JS and WASM files and a small html page. It has to execute client side code to put it all together and build the page.
Both are Single Page Applications - the initially loaded page is the application. The client side code just changes out bits of the DOM to update a "page" or move between "pages".
"Pages" are components, not html pages.
Blazor has two flavours, Blazor WebAssembly and Blazor Server. Both are used to create SPAs (which are a type of application) and both can be configured to use SSR (which is a technology).
More information can be found here.
Blazor Server does Server Side Rendering, but not in the traditional way.
It only delivers a nearly empty HTML page once and from there on it acts like a SPA. Except that the logic runs on the Server and changes to the DOM are pushed with WebSockets (not HTTP). Events are sent in the other direction.
So Blazor Server has the look and feel of a SPA, to both the end user and to the programmer. You can for instance not really use cookies to store state.
But the use of server resources (per user) means it is not nearly as scalable, and you need an always-on good internet connection.

enable download on html from my asp page

I want to be able to download the html contents of my page from a client after receiving a post request (XMLHttpRequest and doing some processing. Is there a setting I must enable for this to be possible? I've tried enabling COORS via
Response.AddHeader("Access-Control-Allow-Origin", "*");
with no success. Has anyone found a solution to this problem?
Update: I am using ASP.NET Web Forms (with NET 4.5)
Well, I think the CORS stuff is for cross origin scripting - to enable JavaScript calls to a domain different than the original request. As far as getting the HTML contents, I believe you mean to get the response of the web server as it is posted back to the client. Not knowing what technology you have used (i.e., MVC, ASPX, etc.) you may want to look into interceptors. They differ depending on the technology. For ASPX, check out....
http://www.codeproject.com/Articles/30907/The-Two-Interceptors-HttpModule-and-HttpHandlers

Open another webpage, logging in through code Asp.Net MVC

I want to be able to login to an external domain webpage through code, and give the resultant page to user.
Tried using HttpWebRequest,
The user agent that makes the request must support JavaScript. The HttpWebRequest doesn’t support JavaScript.
Also found some suggestions about using WebBrowser Control, but that is for Forms apps.
Need some solution for ASP.NET MVC.

Passing C# class to javascript (no web server)

I am writing a desktop application in C# and would like to pass data from C# to an HTML 5 panel (javascript or jquery). I am using CefSharp which embeds Chromium into the application, it successfully loads data from a file with no web server, I have this up and running to display Processing sketches locally within the application (desktop).
The solution I am looking for can't use or require a web server, it has to operate locally. The HTML 5 (CefSharp) browser panel is hosted by the application and does not allow users to navigate to web pages. Its only purpose is to visualise and display data the software generates.
Ideally I would like to do something like the following:
Data in C# ----> (possibly) JSON object ----> object available in embedded browser
The browser has an instance of jQuery if that helps. I'd be grateful if you a small code sample can be provided, it has to operate without a web server and preferably without dumping the C# data to a file which is then loaded by the embedded browser. I want to pass data directly from C# to the embedded browser and have it available for processing.
Any ideas?
References:
https://github.com/chillitom/CefSharp

Asp.net c# web application on phonegap

i'm developing a web application using asp.net and c#, this application must be available on almost wp7.5 and android. I wanted to use phonegap to solve this problem but how can i use .aspx pages on it? It only supports HTML pages, not server side pages.
You can't.
PhoneGap allows you to use client side web technologies (HTML, Javascript & CSS) to build a native app.
It won't, and isn't designed to, work with server side technologies
You can only access aspx pages via html requests (get, post, ajax) on html and parse and show data that comes from aspx page.

Categories