Not getting Startup.Auth file - c#

I am trying to install steam login, for my website, BUT after i have done the installation in nuget package manager console, with the following install code: Install-Package Owin.Security.Providers.Steam I am missing my Startup.Auth.cs. What am i doing wrong?
The project is started without "Individual User Accounts".

The Startup.Auth.cs file should be in your App_Start Folder. Just create a default MVC web application with Individual User Accounts selected as the Authentication type under Change Authentication option to see how its implemented.
For reference:
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;
using Owin.Security.Providers.Steam;
namespace WebApplication
{
public partial class Startup
{
public void ConfigureAuth(IAppBuilder app)
{
//other Config
app.UseSteamAuthentication("your API key");
}
}
}
See here for reference on how to add the Steam login button.
Edit:
Also see here for Adding MVC 5 Identity to our Existing Project.
You may need to add startup.cs to root of your project:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartupAttribute(typeof(WebApplication1.Startup))]
namespace WebApplication1
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}

Related

Asp.net core: Selenium doesn't see geckodriver in current directory

web api core 2.0 project doesn't see geckodriver.exe
How can I fix it?!
I created a asp.net core 2.0 web api project.
I put a geckodriver.exe to directory with project, I changed "Copy to output directory" to "Copy always".
This is my controller:
using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace WebApplication1.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
if (!System.IO.File.Exists("geckodriver.exe"))
{
throw new Exception("error");
}
using (IWebDriver driver = new FirefoxDriver())
{
driver.Navigate().GoToUrl("http://gooogle.com");
}
return new string[] { "value1", "value2" };
}
}
}
When I start my project, I get exception message
OpenQA.Selenium.DriverServiceNotFoundException: 'The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at https://github.com/mozilla/geckodriver/releases.'
I wonder why .net framework mvc application with same code works well!
My question is: how to fix my problem? I can't find a solution on google
The driver is copied to the output directory. Just use the following line of code:
var driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
This happens because the NuGet packages for .NET Core projects are loaded from a global place instead of the packages folder of the .NET Framework projects. To fix it, we need to specify the path to the execution folder.
(source: https://www.automatetheplanet.com/webdriver-dotnetcore2/)
Copy driver.exe to following path:
C:\Users\[userName]\.nuget\packages\selenium.webdriver\3.6.0\lib\netstandard2.0\

ASP.NET PhysicalFileProvider not available in Startup.cs

I am trying to serve static files in a ASP.NET 4.6 web application, MVC 5.2.3 using the Entity Framework. I'm following this tutorial.
I'm getting a compiler error:
The type or namespace name 'PhysicalFileProvider' could not be found
(are you missing a using directive or an assembly reference?)
It seems that the using Microsoft.Extensions.FileProviders is not actually being used (it is grayed out in Visual Studio.
I have tried importing various assemblies without any luck. I'm not a .NET developer and any help would be greatly appreciated.
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Primitives;
using Microsoft.Owin;
using Microsoft.Owin.StaticFiles;
using Microsoft.Extensions.Configuration;
using Owin;
[assembly: OwinStartup(typeof(Monica.Startup))]
namespace Monica
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseStaticFiles(); // For the wwwroot folder
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(), #"MyStaticFiles")),
RequestPath = new PathString("/StaticFiles")
});
}
}
}
You should install the nugget package:
Microsoft.Extensions.FileProviders.Physical
Right click the project -> Manage Nugget Packages -> Browse -> Microsoft.Extensions.FileProviders.Physical -> Install.
The using statement should be available to you afterwards.

Type or namespace name 'OwinStartupAttribute' could not be found

Error
The type or namespace name 'OwinStartupAttribute' could not be found
The type or namespace name 'OwinStartup' could not be found
Code
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Employee.Web.Models.Startup))]
namespace Employee.Web.Models.Startup
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Any help would be appreciated.
Using:
.net 4.0
MVC 4
Microsoft.AspNet.SignalR.SystemWeb (1.1.0.0)
Microsoft.Owin (2.1.0.0)
Microsoft.Owin.Host.SystemWeb (2.1.0.0)
Owin (1.0.0.0)
Visual Studio 2013
Installed singlar after Referencing Microsoft.Owin using the command Install-Package Microsoft.AspNet.SignalR -Version 1.1.3
UPDATE:
I removed [assembly:..
and also added this in web.config:
<add key="owin:AppStartup" value="Employee.Web.Models.Startup" />
The error now says
'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and no extension method 'MapSignalR' accepting a first argument of type 'Owin.IAppBuilder' could be found
To fix that:
Make sure that Microsoft.Owin is installed
Right-click on the
project and click add item and search for "startup"
Now, you already have an OWIN Startup.cs class. click on OWIN Startup
class and just add it under Startup1.cs then the error will be
gone.
Delete the added Startup1.cs
finally, rebuild.
Hope that helps!
Create One Class With Name Startup this will help you..
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
In addition to this, if your startup class is somehow not in your default name space, add a web config line to the area like:
<add key="owin:AppStartup" value="[NameSpace].Startup" />
Here is more explenation.
I removed Microsoft.Owin from my project's references
downloaded the .dll and placed it into the project's bin/ folder
Right clicked references, add, browse, find the .dll, it builds!
Make sure the packages.config version of Owin matches your downloaded version.

How to make the server use the startup.cs instead of Global.asax.cs

I am trying to publish an app in the web but the server searches for Global.asax.cs and I deleted that file and added startup.cs instead.
How can I make the server search for startup.cs instead of Global.asax.cs, or what is the best approach to fix this issue ?
You have to add the Owin package from Nuget and use a startup class looks like this:
using Owin;
using Microsoft.Owin;
[assembly: OwinStartup(typeof(YOURNAMESPACE.Startup))]
namespace YOURNAMESPACE
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
//DO your stuff
}
}
}
Hope this helps

'Owin.IAppBuilder' does not contain a definition for 'MapSignalR'

Error
'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and
no extension method 'MapSignalR' accepting a first argument of type
'Owin.IAppBuilder' could be found (are you missing a using directive
or an assembly reference?)
Code
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(SignalRChat.Startup))]
namespace SignalRChat
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Any connection or hub wire up and configuration should go here
app.MapSignalR();
}
}
}
Any help would be greatly appreciated...
Update
signalR version 2.0.3
Microsoft Owin version 2.0.2
Owin version 1.0.0
Visual Studio 2012
Only install this nuget:
Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
Finally was able to solve it by adding signalR dependencies before adding signalR from NuGet Packages
Step's I followed:
Added Microsoft.Owin //version 2.0.1
Added Microsoft.Owin.Security //version 2.0.1
Added Microsoft Asp.Net SignalR
The reason I discovered was a problem with version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security and then adding a class named Startup.cs with following code:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(webApp.Startup))]
namespace webApp
{
public static class Startup
{
public static void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
Directly adding Microsoft Asp.Net SignalR from NuGet adds version 2.0.2 of Microsoft.Owin and Microsoft.Owin.Security which creates the problem.
Hope it helps someone...!!
Update-Package Owin -Reinstall
worked for me
Install Nuget Package: Microsoft.AspNet.Identity.Owin
I had this same problem. Turns out my .csproj file the first line:
Project ToolsVersion="12.0" didn't match my other files. Changed it to:
Project ToolsVersion="14.0"
and no more compile issue.
Using MVC5, enter your Startup.cs file.
Add IAppBuilder appBuilder to Configure():
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAppBuilder appBuilder)
{
Then, under
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
add appBuilder.MapSignalR();
Asp.Net 5 empty mvc project out of the box creates something that looks like this
using Microsoft.Owin;
using Owin;
namespace DeadlyChat
{
public class Startup
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app)
{
app.MapSignalR();
}
}
}
Took me a while to notice that Configure was supposed to be Configuration and IApplicationBuilder needs to be IAppBuilder. I also pulled off the assembly annotation above the namespace.
I wound up scrapping trying to use Asp.Net 5 couldn't get it to work. Went back to 4.6 and everything worked fine. Followed this walkthrough http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr

Categories