asp.net-core-mvc

IFormFile always null (ASP.NET Core with MVC/Razor)

杀马特。学长 韩版系。学妹 提交于 2021-02-06 07:46:32
问题 I have an ASP.NET Core MVC app attempting to upload an IFormFile. However, the IFormFile is always null. None of the other solutions I've found have solved this issue. What am I doing wrong? Model public class EmailForm { [Display(Name = "Add a picture")] [DataType(DataType.Upload)] [FileExtensions(Extensions = "jpg,png,gif,jpeg,bmp,svg")] public IFormFile SubmitterPicture { get; set; } } Controller public async Task<ActionResult> Contribute([Bind("SubmitterPicture")] EmailForm model) { if

IFormFile always null (ASP.NET Core with MVC/Razor)

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 07:46:25
问题 I have an ASP.NET Core MVC app attempting to upload an IFormFile. However, the IFormFile is always null. None of the other solutions I've found have solved this issue. What am I doing wrong? Model public class EmailForm { [Display(Name = "Add a picture")] [DataType(DataType.Upload)] [FileExtensions(Extensions = "jpg,png,gif,jpeg,bmp,svg")] public IFormFile SubmitterPicture { get; set; } } Controller public async Task<ActionResult> Contribute([Bind("SubmitterPicture")] EmailForm model) { if

Url.Page creates wrong url

风格不统一 提交于 2021-02-05 09:11:44
问题 Have a look at this code: var callbackUrl = Url.Page("/Account/ConfirmEmail", null, new { userId = user.Id, code }, Request.Scheme); The result is this: http://localhost:5000/Account/Register?userId=614d16ae-4e95-4796-8d67-cb829e12585b&code=CfDJ8OeNFdnFCrtCsRU7ofatUuROudlTo%2BFQe84oAiL%2BPJSoYwGH9q1Xadg8XBbpOFg5DiRH1vDoGeQ8l3qIFHjB3NMM3ZDTlQexawj1b%2BJ7P6X3SHoBsYs7jLYwcfGQCbnk1SJA5koFkoDcWj04nsjzQlJMe8ttR0DFdi%2B6TTbWI8WkPBaS083O3aU%2BL2bbYGNwwikhrkbB0nHy4PRzK1LZuZo%3D&page=%2FAccount

NuGet package contentFiles artifacts installed as links in ASP.NET Core MVC project

耗尽温柔 提交于 2021-02-05 07:59:05
问题 We have an internal JavaScript library that we'd like to share between multiple projects. Actually we are already sharing it via file copying, but this has (predictably) resulted in multiple forks of the code. The consuming projects are a mix of "full" ASP.NET (MVC and Web Forms) and ASP.NET Core MVC. (I'm planning on creating two separate packages.) Installing into ASP.NET projects seems to work fine, but I'm having problems with ASP.NET Core. Initially I had all the artifacts within a files

How to publish asp.net core app Dlls without having to stop the application

时光怂恿深爱的人放手 提交于 2021-02-04 22:10:23
问题 When i try to publish the .net core app Dlls using ftp via filezilla tool it shows an error message that the file is in use by another process. It's understandable that the above message shows because the the file is used by dotnet.exe which is a separate process. To overcome the issue i have to stop the application in iis each time then upload the dlls and then restart it. Due to which a very small down time is experienced , the asp.net identity session expires and it needs rdp to the server

How to publish asp.net core app Dlls without having to stop the application

 ̄綄美尐妖づ 提交于 2021-02-04 22:08:40
问题 When i try to publish the .net core app Dlls using ftp via filezilla tool it shows an error message that the file is in use by another process. It's understandable that the above message shows because the the file is used by dotnet.exe which is a separate process. To overcome the issue i have to stop the application in iis each time then upload the dlls and then restart it. Due to which a very small down time is experienced , the asp.net identity session expires and it needs rdp to the server

Executing code after user has been authenticated using Azure Active Directory

前提是你 提交于 2021-02-04 21:06:59
问题 I created an ASP.NET MVC Core (1.1.0) application using VS2015. In the dialog, I selected the option to connect to Azure AD, so VS generated the boilerplate code and, as expected, the app redirects me to Microsoft's login page, where I can login with my work&school account. Now, after the user logs in, and before serving the first page (say, /home/index) I need to get some information from the user that I have stored in a database (like the display name, the contact information such as an

Executing code after user has been authenticated using Azure Active Directory

╄→гoц情女王★ 提交于 2021-02-04 21:06:15
问题 I created an ASP.NET MVC Core (1.1.0) application using VS2015. In the dialog, I selected the option to connect to Azure AD, so VS generated the boilerplate code and, as expected, the app redirects me to Microsoft's login page, where I can login with my work&school account. Now, after the user logs in, and before serving the first page (say, /home/index) I need to get some information from the user that I have stored in a database (like the display name, the contact information such as an

How to delete a file after it was streamed in ASP.NET Core

五迷三道 提交于 2021-02-04 19:16:29
问题 I would like to delete a temporary file after returning it form action. How can i achieve that with ASP.NET Core: public IActionResult Download(long id) { var file = "C:/temp/tempfile.zip"; var fileName = "file.zip; return this.PhysicalFile(file, "application/zip", fileName); // I Would like to have File.Delete(file) here !! } The file is too big for returning using memory stream. 回答1: File() or PhysicalFile() return a FileResult -derived class that just delegates processing to an executor

How can I share session among subdomains in ASP.NET Core?

两盒软妹~` 提交于 2021-02-04 15:09:19
问题 I have a website which has subdomains such as ali.sarahah.com but if a user logs in from www.sarahah.com then goes to ali.sarahah.com the session is not saved. After searching I added the following in Startup.cs : app.UseCookieAuthentication(new CookieAuthenticationOptions { CookieDomain = ".sarahah.com" }); I found out that .AspNetCore.Identity.Application cookie domain is still showing the subdomain and not the the domain and that session problem is still there. Am I doing something wrong?