asp.net-mvc-5

How do I upload a file to Azure blob storage from a MVC view

放肆的年华 提交于 2019-12-06 03:58:33
问题 I am coding a MVC5 internet application and would like some help to upload a file from my own filesystem to an Azure Blob. Here is my Azure upload code function: public void UploadFileToBlobStorage(string containerName, string blockBlogName, string fileName) { // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client. CloudBlobClient blobClient

ASP.NET MVC 5 - create own login

懵懂的女人 提交于 2019-12-06 03:47:33
Hy, I'm very new to MVC 5 (or any other MVC). I want to create my own custom login with registration. Can somebody point me to this? The login should have a simple email and password textbox. The registration should have additional data like first/lastname, age, etc. which stored in a table (user) and a dropdownbox with roles to select (stored in table "roles"). After successful login/registration should the user be redirected to the dashboard. Or is there a good tutorial about this for MVC 5 .. I just found one for MVC 4 . Thanks for help :) Try this [AllowAnonymous] public ActionResult Login

Get all Area, Controller and Action as a tree

孤者浪人 提交于 2019-12-06 03:34:17
I need to get all areas that has been registered as list and all of their controllers as a sub list and the same thing for actions. something like this: AdminArea HomeController Index Add ... OtherController ... AnotherArea HomeController Index ... ... I have checked the answer of this question, and this one , but they are not what i'm looking for. The first one return all the routes that has been registered and the second one return all controllers at once. Update Ok, with the below code i can get all the areas and with the answer of the second question i can get all the controllers, but i

How do I show Exception message in shared view Error.cshtml?

半城伤御伤魂 提交于 2019-12-06 03:33:45
问题 If I start with a new MVC 5 project, in web.config setting customErrors mode="on" allows the shared view 'Error.cshtml' to show when I force (raise) an exception, but it only shows the following text... Error. An error occurred while processing your request. How do I pass information to this view to display more relevant info, such as what error occurred? Can I use this view if I use the Global.asax method... protected void Application_Error() ? 回答1: Override the filter: // In your App_Start

How to set culture as globally in mvc5

假如想象 提交于 2019-12-06 03:33:12
问题 I am using resource files to switch languages in my web application which is build in mvc5 In index files its reading the culture value which i set. I am calling the set culture method from layout.cshtml and calling its value with the following code. @{ Layout = "~/Views/Shared/_Layout.cshtml"; if (!Request["dropdown"].IsEmpty()) { Culture = UICulture = Request["dropdown"]; } } in index page the language is loading correctly but when from there when i go to the next page its loading the

NullReferenceException with Owin

此生再无相见时 提交于 2019-12-06 03:06:53
问题 I've just cloned a project to a new machine and I'm getting a hard-to-debug NullReferenceException on a MVC site with OWIN: [NullReferenceException: Object reference not set to an instance of an object.] Microsoft.Owin.Security.Cookies.<AuthenticateCoreAsync>d__0.MoveNext() +664 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices

Sitecore, custom MVC controllers and routes

北战南征 提交于 2019-12-06 02:48:01
I have a website defined in Sitecore's site definitions. The path to it is /localhost/mysite/home . And it works. I need to create a custom controller to submit forms with an API bypassing Sitecore. So I have FormsController (inheriting from MVC controller) with an action named "Test" taking no parameters. I defined the route in the initialize pipeline like this: public class Initialize { public void Process(PipelineArgs args) { MapRoutes(); GlassMapperSc.Start(); } private void MapRoutes() { RouteTable.Routes.MapRoute( "Forms.Test", "forms/test", new { controller = "FormsController", action =

Asp.net MVC 5 redirect to Account/Login

人走茶凉 提交于 2019-12-06 02:47:05
I'm learning ASP.NET MVC. I have MVC version 5.2.2.0 I attached Authorize attribute to an action method Index() in Employee controller. In the Web.config file, I changed authentication tag data as follows: <system.web> <authentication mode="Forms"> <forms loginurl="~/Authentication/Login"></forms> </authentication> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web> What is expected is that when localhost:port/Employee/Index is accessed, the user should be redirected to localhost:port/Authentication/Login But it is redirecting to localhost

The type RoleStore<IdentityRole> is not assignable to service IRoleStore<IRole>

不羁的心 提交于 2019-12-06 02:43:16
问题 I'm trying to set up dependency injection with Autofac for project using MVC5 and EF6. I'm having a hard time figuring out how to decouple correctly the EntityFramework.RoleStore<EntityFramework.IdentityRole> implementation. I would like have dependency only on Identity.IRoleStore<Identity.IRole> but I'm aware that for generic classes I need to specify the concrete implementation, not the interface. This is what I tried: builder.RegisterType<IdentityRole>().As<IRole>(); builder.RegisterType

Rotativa ActionAsPdf() Very Slow

ε祈祈猫儿з 提交于 2019-12-06 02:34:59
Using Rotativa 1.6.4 from NuGet and have noticed the following issue using the code below. ActionAsPdf hangs randomly for indeterminate amount of time. Code below that is hanging: var pdfResult = new ActionAsPdf("Report", new {id = Request.Params["id"]}) { Cookies = cookieCollection, FormsAuthenticationCookieName = FormsAuthentication.FormsCookieName, CustomSwitches = "--load-error-handling ignore" }; Background info that may help: The customSwitches is in use to ignore a documented issue calling wkhtmltopdf.exe using the ActionAsPdf, but it does not suppress errors in the code only in the