await _signInManager.GetExternalLoginInfoAsync() is giving me principleClaim but await _signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKey, isPersistent: false, bypassTwoFactor: true); is always returing false /failed . Could some one help me ?
External authentication using Saml2
Basic Authentication with custom logic
Hi,
i want to implement a simple authentication system in my new .net core 2.1 app .using (username/password)
this is a port of an existing webform application .
the usernames and passwords are already stored in an existing database in crypted format .
actually this website is a readonly view or app of a database used by an existing desktop application .
so the users come with their own usernames and passwords . i check them using a custom algorithm and if it's ok the user is redirected to the app page .
i have found this wich seem to do exactely what i want :
http://csharp-video-tutorials.blogspot.com/2016/10/implementing-basic-authentication-in.html
unfortunately it's use some classes that are no longer in .net core 2.1 like AuthorizationFilterAttribute
what's the alternative to this please in newer versions, I do not want overcomplicated things nor reinventing the wheel ... ;)
thanks .
Publish a self contained web application in shared hosting .
Hi,
is it possible to make a self contained web application that contain everything needed to work ?
the app code , all the dependencies, the runtime framework, , etc etc to publish on a shared web hosting for developpement tests purpose ?
thanks .
Cascading Checkboxes
Hello Guys,
I am Using Asp.net core, but some of the features I am not able to work on.
I wanted to populate a Parent-Child checkbox from database.
This is what I implemented but it is just fetching data I want on parent click child checkboxes should get open and once i selected child checkboxes then it should save In database.
<tr>
@for (int i = 0; i < Model.Services.Count; i++)
{<td >
@Html.CheckBoxFor(model => model.Services[i].is_active)
@Html.DisplayFor(model => model.Services[i].Service)
@Html.HiddenFor(model => model.Services[i].Parent)
@Html.CheckBoxFor(model => model.Services[i].is_active)
@Html.DisplayFor(model => model.Services[i].SubService)
@Html.HiddenFor(model => model.Services[i].Child)
@Html.TextBoxFor(model => model.Services[i].Rate, new { @class = "form-control" })</td>
Error on post Back
Whenever I Postback any page I am getting this error as ArgumentNullException: Value cannot be null for drop-down list or list.
but when I am going through HttpGet I am getting data. so what could be the solution?
I want the working combination of jquery, jmoment, jbootstrap, jbootstrap datetimepicker
in .net core app jquery2.2.0min, bootstrap 3.3.7min was in working condition.
To use bootstrap datetimepicker 4.17.45, i had to upgrade. Now all versions got
tangled and latest jquery3.3.7 is not working for me. I want the working combination of jquery, jmoment, jbootstrap, jbootstrap datetimepicker. Please help.
Using Sessions
Hi, I am having a problem implementing a session
I have in List.cshtml.cs
HttpContext.Session.SetInt32("CurrentUserID", 100);
ViewData["userid"] = HttpContext.Session.GetInt32("CurrentUserID");in the view file List.cshtml i have
@ViewData["userid"]
This then displays the value of 100, so the session has been started
If i go to details.cshtml and use
@ViewData["userid"]
No value is returned,
So do i have to use ViewData["userid"] = HttpContext.Session.GetInt32("CurrentUserID"); in every .cs file, where i want to see the session variable returned on the view?
Am i doing this correctly?
thanks
Asp Core InProc Session use without serialization
(apologies for posting this here and on stack overflow, I don't know which is the best practical avenue for getting a response)
Is there anyway of using InProc session in Asp.Net Core with having to serialize the data each time? We have an website that's 15+ years old, it uses a lot of Session up to and including storing DataSets in the session. Serializing the data on every call is (probably) going to be a big hit.
I'm aware that InProc session can be lost at any point and you wouldn't architect a modern website this way, but this is the only issue that's stopping us migrating to Core (we've already done the handlers and modules)
Show Blank Page After Ajax Call
My Code Is Work Correctly For Upload and Store files,
View
<form asp-action="Create" id="Form_Id" enctype="multipart/form-data" asp-controller="ProjectFiles"
data-ajax="true"
data-ajax-method="Post"
data-ajax-mode="replace"
data-ajax-success="Create_Success"
data-ajax-failure="Create_Failure"><div class="form-group"><div class="form-group"><label asp-for="File_Name" class="control-label"></label><input asp-for="File_Name" class="form-control" /><span asp-validation-for="File_Name" class="text-danger"></span></div><div class="form-group"><label asp-for="File_Title" class="control-label"></label><input asp-for="File_Title" class="form-control" /><span asp-validation-for="File_Title" class="text-danger"></span></div><div class="form-group"><label asp-for="File_Description" class="control-label"></label><input asp-for="File_Description" class="form-control" /><span asp-validation-for="File_Description" class="text-danger"></span></div><div class="form-group"><label asp-for="fileUpload" class="control-label"></label><input type="file" asp-for="fileUpload" class="form-control" /><span asp-validation-for="fileUpload" class="text-danger"></span></div><div class="form-group"><input type="submit" value="Create" class="btn btn-default" /></div></div></form>Controller
function uploadFiles(inputId) {
var input = document.getElementById(inputId);
var files = input.files;
var formData = new FormData();
for (var i = 0; i != files.length; i++) {
formData.append("files", files[i]);
}$.ajax({
type: 'POST',
url: '/ProjectFiles/Create',
dataType: 'json',
data: JSON.stringify(formData),
success: function (data) {
alert("asd");
},
error: function (ex) {
alert("dasdsa");
}
});
}
when the controller return json its show blank page that wirte it {Success:true}
but I Want Show execute success method after ajax call .
How To Write it That After Controller Show Swal()
Validate date using culture
Hi all,
I have a ASP.Net core app with a register form containing a birthdate field.
I can't get the validation process to work with the format dd-mm-yyy,
I've tried these on my model:
[Required]
[Display(Name = "Date de naissance")]
// [DataType("datetime-local")]
//[DataType("dd-MM-yyyy")]
//[DisplayFormat(DataFormatString = @"{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime BirthDate { get; set; }The view:
<div class="form-group row"><label asp-for="BirthDate" class="col-4 col-form-label"></label><div class="col-8"><input id="birthdate" asp-for="BirthDate" class="form-control datepicker" value="" /><span asp-validation-for="BirthDate" class="text-danger"></span></div></div>
I always get "Invalid date format"
Dotnet CLI builds much slower than VS2017
I have an ASP Core 2.0 project that builds via VS2017 (community) in 2.5 minutes. When I build with dotnet (same machine) it takes 8.5 minutes.
I see similar issues with other projects as well. When I first started investigating this the ASP project took 20+ minutes to build. I discovered that Windows Defender was the culprit there. I added some exceptions (for Nuget and project file locations)
and that lowered the time to 8+ minutes.
I am at a loss as to why there is such a difference between VS and CLI.
Machine is a MacBook Pro, I7, 16GB RAM running Windows 10 Pro via Bootcamp. It is a dev box so installed software is mostly tools (VS, Code, Sublime, Postman, Fiddler).
Taskman is not showing anything mysterious running or consuming resources.
If anyone can shed any light on this it would be appreciated.
XML File Not Loading in .NET Core Web API
Dear Friends,
I am trying to load xml file in Web API but it is giving me following error:
System.IO.DirectoryNotFoundException: 'Could not find a part of the path 'E:\Task\a.xml'
Same File loads successfully in .NET Core Consol API. Following code lines I am using:
XmlDocument xmlDoc = new XmlDocument(); // Create an XML document object
xmlDoc.Load(@"E:\Task\a.xml"); // Load the XML document from the specified file
Any help will be much appreciated.
Thanks,
Pervaiz Khan.
Support with Project! ASP CORE.
I would like to know if it would be possible to have someone help me with support in stalling the project references and dependencies, required to launch a project tutorial website that i have purchased from a publisher. I do not have enough experience in core.net to install the requirements to run the project. When i load the project solution explore has the yellow exclamation marks on several of the references files! If i had knowledge of to do it would be done. Beside that I have tried installing and updating dependencies but no luck there so that why I would ask for help with TEAM-VIEWER, to install references.
Hot reload routes with WebHost (Kestrel)
Hello,
I write a little web API server with C# and the dotnet core, which load http routes from files. I'm using the "Configure" method of the Startup class to do this. I want if the configuration files change, add, modify or remove route without restart my process. It's easy to catch file events with a FileSystemWatcher but i don't see if there is way to push the change in the route handlers collection after the start of the WebHost. I read the source code but it seems that there is no solution to do this. I'm wrong or not ?
thanks for your help
Login With Email ASP.NET Core 2.0 Razor Pages
When I dove into the default code for the windows default razor page project with authentication I found that the username is automatically set as the email. I was able to change that so users can set their own usernames upon registering. What I then discovered is that the code for logging in uses the username to login NOT the email address. What I would like to do is change it so that people login with their Emails not Usernames.
It all says email, but it is pulling it as the UserName...
[Required]
[EmailAddress]
public string Email { get; set; }var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: true);
Custom text in dropdown list in ASP.NET Core 2.0 Razor Pages
Hey guys I am back to this now! I have learned a ton over the past few months, yet I still have this question. I do have more context to give on this subject, so her we go!
I am creating a web app with ASP.NET razor pages, these are super easy to navigate and really intuitive. I am creating CRUD lists linked to a SQL database I have Create and Edit pages, I also have a index page to view all items in the database.
REQUEST:
In the Create and Edit pages I would like to have some of the inputs as: dropdown lists(linked to array from column"X" in SQL database) - with option for custom text.
(I know there has to be a way to do this in jquery, just I don't really know jquery right now, if that is the only way, I can learn to do it)
Below is my code for the Edit.cs and Create.cs
namespace BookList_Razor.Pages.BookList
{
public class EditModel : PageModel
{
public List<String> columnData = new List<String>();
public IEnumerable<SelectList> DropDownList { get; set; }
public SelectList authorDropDown;
private ApplicationDbContext _db;
public EditModel(ApplicationDbContext db)
{
_db = db;
}
[BindProperty]
public Book EditBook { get; set; }
[TempData]
public string Message { get; set; }
public void OnGet(int id)
{
EditBook = _db.Books.Find(id);
DataBaseDropDown();
}
public async Task<IActionResult> OnPost()
{
if (ModelState.IsValid)
{
var bookInDb = _db.Books.Find(EditBook.Id);
bookInDb.ISBN = EditBook.ISBN;
bookInDb.Title = EditBook.Title;
bookInDb.Author = EditBook.Author;
bookInDb.Price = EditBook.Price;
bookInDb.Avaibility = EditBook.Avaibility;
await _db.SaveChangesAsync();
Message = "Book Updated Successfully!";
return RedirectToPage("Index");
}
return RedirectToPage();
}
protected void DataBaseDropDown()
{
using (SqlConnection connection = new SqlConnection("Server=(localdb)\\mssqllocaldb;Database=BookList_Razor;Trusted_Connection=True;MultipleActiveResultSets=True"))
{
connection.Open();
string query = "SELECT Author FROM Books";
using (SqlCommand command = new SqlCommand(query, connection))
{
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
columnData.Add(reader.GetString(0));
}
}
}
}
authorDropDown = new SelectList(columnData);
}
}
}namespace BookList_Razor.Pages.BookList
{
public class CreateModel : PageModel
{
private ApplicationDbContext _db;
[TempData]
public string Message { get; set; }
public CreateModel(ApplicationDbContext db)
{
_db = db;
}
[BindProperty]
public Book NewBook { get; set; }
public void OnGet()
{
}
public async Task<IActionResult> OnPost()
{
if (!ModelState.IsValid)
{
return Page();
}
_db.Books.Add(NewBook);
await _db.SaveChangesAsync();
Message = "New Book Added Successfully!";
return RedirectToPage("Index");
}
}
}namespace BookList_Razor.Model
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public DbSet<Book> Books { get; set; }
}
}namespace BookList_Razor.Model
{
public class Book
{
public int Id { get; set; }
public string Title { get; set; }
public string Author { get; set; }
public string ISBN { get; set; }
public int Avaibility { get; set; }
public double Price { get; set; }
}
}want to use bootstarp navbar dropdown list for .net core app
in the .net core app how to use bootstarp navbar dropdown list for mvc. In latest versions of bootstrap dropdown facility cannot be accomodated with navbar.
Docker Build Error using Visual Studio 2017
HI All,
I'm new to Docker and create a simple .Net core application with Docker by using visual studio 2017.
When I try to build the application, it throws the following error message. Can anyone help me to resolve it. Thanks in advance.
Severity Code Description Project File Line Suppression State
Error Building dockerwebpage
Creating dockercompose3484149639777294787_dockerwebpage_1 ...
[1A[2K
Creating dockercompose3484149639777294787_dockerwebpage_1 ... [31merror[0m
[1B
ERROR: for dockercompose3484149639777294787_dockerwebpage_1 Cannot start service dockerwebpage: container 27dfa62c467d7d0701aa14979ef8be899972244d72b1e316ed7e9c49b684d2a1 encountered an error during CreateProcess: failure in a Windows system call: The system
cannot find the file specified. (0x2) extra info: {"CommandLine":"powershell -Command [System.Threading.Thread]::Sleep([System.Threading.Timeout]::Infinite)","User":"ContainerUser","WorkingDirectory":"C:\\app","Environment":{"ASPNETCORE_ENVIRONMENT":"Development","ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_USE_POLLING_FILE_WATCHER":"1","NUGET_FALLBACK_PACKAGES":"c:\\.nuget\\fallbackpackages","NUGET_PACKAGES":"C:\\.nuget\\packages","NUGET_XMLDOC_MODE":"skip"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
ERROR: for dockerwebpage Cannot start service dockerwebpage: container 27dfa62c467d7d0701aa14979ef8be899972244d72b1e316ed7e9c49b684d2a1 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
extra info: {"CommandLine":"powershell -Command [System.Threading.Thread]::Sleep([System.Threading.Timeout]::Infinite)","User":"ContainerUser","WorkingDirectory":"C:\\app","Environment":{"ASPNETCORE_ENVIRONMENT":"Development","ASPNETCORE_URLS":"http://+:80","DOTNET_RUNNING_IN_CONTAINER":"true","DOTNET_USE_POLLING_FILE_WATCHER":"1","NUGET_FALLBACK_PACKAGES":"c:\\.nuget\\fallbackpackages","NUGET_PACKAGES":"C:\\.nuget\\packages","NUGET_XMLDOC_MODE":"skip"},"CreateStdInPipe":true,"CreateStdOutPipe":true,"CreateStdErrPipe":true,"ConsoleSize":[0,0]}
Encountered errors while bringing up the project..
For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting docker-compose C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets 346
Thanks,
Anand
for AddMvcCore().AddJsonFormatters(); System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
The Startup for my Web API works on my development machine, but after a recent deployment unexpectedly stopped working on my IIS staging webserver (and previous deployments it did work).
I get this exception;
Application startup exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.ComputeClassification(String dependency)
at Microsoft.AspNetCore.Mvc.Internal.DefaultAssemblyPartDiscoveryProvider.CandidateResolver.<GetCandidates>d__4.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Properties.API.Startup.ConfigureServices(IServiceCollection services)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Staging
And the code is;
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddMvcCore().AddJsonFormatters();
services.Configure<IISOptions>(options => new IISOptions
{
AutomaticAuthentication = true,
ForwardClientCertificate = false,
ForwardWindowsAuthentication = false
});
var connectionStringMSurveyV2 = Configuration.GetConnectionString("MSurveyV2Db");
services.AddScoped<MSurveyV2Db>(_ => new MSurveyV2Db(connectionStringMSurveyV2));
var connectionStringSir = Configuration.GetConnectionString("SirDb");
services.AddScoped<SirDb>(_ => new SirDb(connectionStringSir));
services.AddScoped<IPropertiesRepo, PropertiesRepo>();
services.AddScoped<ISirUoW, SirUoW>();
services.AddScoped<IPropertyUoW, PropertyUoW>();
services.AddScoped<Services.IMailService, Services.MailService>();
}So what is going on here? Should I be looking at my JSON files - which I have done? How do I find out what key is causing the problem?
want to use bootstarp navbar dropdown list in .net core _layout
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown"
asp-area="" asp-controller="Staffs" asp-action="Index">
Staff
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a asp-area="" asp-controller="Staffs" asp-action="Index">Staff</a></li>
<li><a asp-area="" asp-controller="Certificates" asp-action="Index">Certificate</a></li>
</ul>
</li>