I try to login my selfhosted website via ip address and its dont working(using owin) i tried using this Self hosted OWIN and urlacl but it still not working this is my code:
Main:
{
string baseAddress = "http://*:9000/";
// Start OWIN host
using (WebApp.Start<Startup>(url: baseAddress))
{
// Create HttpCient and make a request to api/values
HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync("http://localhost:9000/api/check").Result;
Console.WriteLine(response);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
Console.ReadLine(); // Keeps the host from disposing immediately
}
}
SetUp:
public class Startup
{
// This code configures Web API contained in the class Startup, which is additionally specified as the type parameter in WebApplication.Start
public void Configuration(IAppBuilder appBuilder)
{
// Configure Web API for Self-Host
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
appBuilder.UseWebApi(config);
}
}
and controler:
using System.Collections.Generic;
using System.Web.Http;
using System.Net.Http.Headers;
using System.Net.Http;
using System;
using Owin;
using Microsoft.Owin;
namespace Owin_Testing
{
public class CheckController : ApiController
{
[HttpGet]
[Route]
public HttpResponseMessage Get()
{
var response = new HttpResponseMessage();
response.Content = new StringContent("<!DOCTYPE html><html lang=\"en\"><h1>Working</h1></html>");
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
}
}
}
When i try localhost:9000 or 127.0.0.1:9000 but with ip its still dont work(its console application) i made tcp inbound role on port 9000 and tried on my rdp too
Aucun commentaire:
Enregistrer un commentaire