1
Answer

WEB API Self Hosting Error

Photo of Bhushan Gupta

Bhushan Gupta

7y
226
1
 
 
 
Error coming: {"The following errors occurred while attempting to load the app.\r\n - No 'Configuration' method was found in class 'WebPIHTTPServices.StartUp, WebAPIHTTPServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.":""}
 
I have created a console application for web api self hosting through owin and added NuGet package Microsoft.OWIN related..
 
 
First class is this: 
 
using Owin;
using System.Web.Http;
namespace WebAPIHTTPServices
{
public class StartUp
{
public void Configration(IAppBuilder app)
{
var config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
app.UseWebApi(config);
}
}
}
 
 ------------------------------
using System;
using Microsoft.Owin.Hosting;
namespace WebAPIHTTPServices
{
public class Program
{
static void Main(string[] args)
{
using (WebApp.Start<StartUp>("http://localhost:12345"))
{
Console.WriteLine("Web Server is running");
Console.WriteLine("For Quit");
Console.Read();
}
}
 
Advance thanks 
 
 

Attachment: Console.rar

Answers (1)

1
Photo of Vulpes
NA 98.3k 1.5m 13y
You can check for a string being either null or empty with:

if (String.IsNullOrEmpty(strResult))
{                
   label1.Text = "INCORRECT USER/PASS!";
}
else
{              
   label1.Text = "YOU ARE LOGGED IN!";
}
Accepted
0
Photo of mike Delvotti
NA 287 0 13y
Thanks Vulpes, that was bang on, I've been going round in circles with that one.