Find Jobs
Hire Freelancers

I need a simple httplistener in a core .net app to allow local server on another port to connect. No middleware stack. Barebones

$30-250 USD

Selesai
Dibuat sekitar 1 tahun yang lalu

$30-250 USD

Dibayar ketika dikirim
I'm attempting to use C# console app HttpListener in core 2.1 to serve from one localhost port to another using POST / application/json fetch. I have only the callback on the listener sending my JSON data to a web page in my browser. Check. I need my react app on the same server to go to the same localhost port (not on the Internet) to get the data. It REFUSES to send the data. How do I augment the HttpListener to accept any traffic from react localhost:3000 etc, to my C# HttpListener object. It is happy with a browser, but fetch (post) is getting refused. Simple solutions requested. No stacks, no MVC middleware services etc. Barebones. This is all back end systems that are isolated to internal network. If I use a browser window, it debugs showing one request and cors error. If I use the react app, the debug shows two requests, both httpmethod='POST' and doubles the request. I figure it might be timing. But I need to either understand why it is coming in twice as a fetch from react (assuming one is the preflight request and how to respond in code) or set up the httplistener to responded on preflight automatically before sending data.
ID Proyek: 36578817

Tentang proyek

6 proposal
Proyek remot
Aktif 1 tahun yang lalu

Ingin menghasilkan uang?

Keuntungan menawar di Freelancer

Tentukan anggaran dan garis waktu Anda
Dapatkan bayaran atas pekerjaan Anda
Uraikan proposal Anda
Gratis mendaftar dan menawar pekerjaan
Diberikan kepada:
Avatar Pengguna
Hey man, if you are a developer, its easy and you can fix it by yourself. The issue is when using the fetch API with POST method, the browser sends a "preflight" OPTIONS request before the actual POST request. You need to modify your C# HttpListener to handle OPTIONS requests and respond with appropriate CORS headers. Here's a example: public void HandleRequest(HttpListenerContext context) { HttpListenerRequest request = [login to view URL]; HttpListenerResponse response = [login to view URL]; // Set common CORS headers [login to view URL]("Access-Control-Allow-Origin", "http://localhost:3000"); // or "*" for all [login to view URL]("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With"); [login to view URL]("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); if ([login to view URL] == "OPTIONS") { // Preflight request: return OK status code [login to view URL] = (int)[login to view URL]; [login to view URL](); } // Handle POST or other requests here... } Replace "http://localhost:3000" with your React app's actual origin or use "*" to allow all origins (not recommended for production). Include all headers your fetch request might use in the "Access-Control-Allow-Headers" line. Cheers (this is not a bid but an advice for free).
$30 USD dalam 7 hari
5,0 (2 ulasan)
2,9
2,9
6 freelancer menawar dengan rata-rata $113 USD untuk pekerjaan ini
Avatar Pengguna
Hi Dear sir I understand that you're looking for a simple httplistener in a core .net app to allow local server on another port to connect. No middleware stack. Barebones. I believe I am the perfect fit for this project because of my extensive knowledge of C# programming and specifically core 2.1. I have the skills necessary to help you achieve your goal: I have experience working with C# console apps, specifically HttpListeners, which is what you need for this project. This makes me the perfect fit for this job as I can easily understand how to augment the httplistener to respond on preflight automatically before sending data. Additionally, I never use stacks or MVC middleware services when building my apps, instead opting for a barebones approach so they are isolated to the internal network only. I would be more than happy to discuss this project further with you if you feel my skillset would be best suited to meet your needs? Please don't hesitate to contact me if you have any questions or would like more information about me or my services in general. Thank you for considering me for this position!
$200 USD dalam 3 hari
5,0 (4 ulasan)
4,6
4,6
Avatar Pengguna
Hi. Experienced .Net developer here with 10+ years of hands-on experience in Web development. I've worked on numerous SaaS-based web applications during the course of this time, a few mentioned in my portfolio. To understand this scope better, I would appreciate your answers to my following relevant questions: 1. Can you share the complete scope of this project? 2. What are the user types of this application? 3. Do you have mockup designs for the website? Happy to provide you with my relevant portfolio work within the chat. Kindly initiate the chat so we can thoroughly discuss the scope of this project. Thanks!
$140 USD dalam 7 hari
0,0 (0 ulasan)
0,0
0,0

Tentang klien

Bendera UNITED STATES
Sunbury, United States
5,0
1
Memverifikasi Metode pembayaran
Anggota sejak Mei 14, 2023

Verifikasi Klien

Terima kasih! Kami telah mengirim Anda email untuk mengklaim kredit gratis Anda.
Anda sesuatu yang salah saat mengirimkan Anda email. Silakan coba lagi.
Pengguna Terdaftar Total Pekerjaan Terpasang
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Memuat pratinjau
Izin diberikan untuk Geolokasi.
Sesi login Anda telah kedaluwarsa dan Anda sudah keluar. Silakan login kembali.