asp.net-mvc-5

C# API Controller Custom Filter with HttpActionContext Redirect to controller?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-17 05:27:29
问题 Is there a way to create a custom filter with an API controller to redirect to a MVC controller? After looking around a bit his is what i have. public class APIHasOneOfThesePermissions : ActionFilterAttribute { protected UserManager<ApplicationUser> UserManager { get; set; } private SAMPortal.DAL.SAMPortalContext db = new DAL.SAMPortalContext(); public string[] Permissions { get; set; } public APIHasOneOfThesePermissions(string[] Permissions) { this.UserManager = new UserManager

C# API Controller Custom Filter with HttpActionContext Redirect to controller?

六眼飞鱼酱① 提交于 2020-01-17 05:27:04
问题 Is there a way to create a custom filter with an API controller to redirect to a MVC controller? After looking around a bit his is what i have. public class APIHasOneOfThesePermissions : ActionFilterAttribute { protected UserManager<ApplicationUser> UserManager { get; set; } private SAMPortal.DAL.SAMPortalContext db = new DAL.SAMPortalContext(); public string[] Permissions { get; set; } public APIHasOneOfThesePermissions(string[] Permissions) { this.UserManager = new UserManager

ASP.Net MVC: how to write unit test code when working with ValidationAttribute and IClientValidatable

最后都变了- 提交于 2020-01-17 05:09:46
问题 apologized to post bit similar question here. i am bit familiar with asp.net mvc but very new in unit testing. do not think that i know lot just see my reputation in stackoverflow. i like to know how to write unit test code for IsValid and IEnumerable<ModelClientValidationRule> GetClientValidationRules here i am pasting my code including my model. so anyone help me to write unit test code for the above two function. i am new in unit testing and working with VS2013 and using VS unit testing

Image resizing script is not returning a proper stream for further handling

梦想与她 提交于 2020-01-17 05:06:26
问题 Current project: ASP.NET 4.5.2 MVC 5 I am trying to leverage the TinyPNG API, and if I just pipe the image over to it, it works great. However, since the majority of users will be on a mobile device, and these produce images at a far higher resolution than what is needed, I am hoping to reduce the resolution of these files prior to them being piped over to TinyPNG. It is my hope that these resized images will be considerably smaller than the originals, allowing me to conduct a faster round

How can I use RedirectToAction to pass an object to a new Action in MVC 5

断了今生、忘了曾经 提交于 2020-01-17 04:59:07
问题 I have this scenario. A form (ForexPayment) is filled by a user, he/she then clicks Next . I then show new page (ForexPaymentConfirmation) with just the labels and values (i.e. a read-only confirmation page) so he/she can either Submit or Cancel the request. My questions: How do i use return RedirectToAction("ForexPaymentConfirmation"); to pass an object containing the Payment Information from one view to the next? One option would be to store the Payment Information in the Current Session

How to retrieve user details from database and display in a view [MVC 5 application,,Identity User]

白昼怎懂夜的黑 提交于 2020-01-17 02:20:12
问题 I just started creating an mvc 5 application ,I'm using default Identity user database for user data management,But I added some more fields like First Name ,Last Name ,Email Id to this database using migration,Now I need to display this all detail in a view page (as a profile page) ,but I don't know how to retrieve Identity user data from default database ,I am a new mvc developer can you help me my model class namespace WebApp.Models { public class ExternalLoginConfirmationViewModel {

Checking property of EF6 model to see if it has a value or not?

不问归期 提交于 2020-01-17 01:39:07
问题 I am trying to figure out how to check a property of my EF 6 model to see if it contains a value or not. The property is an INt64 so I can't use string.Empty and I can not just compare it to an empty string with out converting it. How can I modify this check so it will return "No" if there is no value in "LogoFileID"? HasLogo = (section.LogoFileID != string.Empty) ? "Yes" : "No"; Here is my model public class Section { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Int16 ID {

In MVC how to call .ashx handler file through jquery

心已入冬 提交于 2020-01-16 23:11:48
问题 In mvc i need to call .ashx handler file through jquery. i tried the bleow code $("#btnUpload").click(function (evt) { var fileUpload = $("#file1").get(0); var files = fileUpload.files; var data = new FormData(); for (var i = 0; i < files.length; i++) { data.append(files[i].name, files[i]); } var options = {}; options.url = "FileUploadHandler.ashx"; options.type = "POST"; options.data = data; options.contentType = false; options.processData = false; options.success = function (result) { alert

MVC 5 Auto Refresh From Controller

六月ゝ 毕业季﹏ 提交于 2020-01-16 18:33:21
问题 I am trying to load a excel file, from a local webserver, then refresh the page every 5min or so, just incase that file has been replaced... It is for displaying a schedule, someone will update it and throughout the plant, the page will be displayed on a monitor and the output will change... I thought this was going to be super simple, and I would just add a refresh to the header of the .html file and be done, but I think that would only work if I just use the regular return View();... Since

Add related entities with ASP.NET MVC and Razor?

不羁的心 提交于 2020-01-16 18:33:15
问题 I have a Person class that has a navigation property ICollection<Address> Addresses . The Address entity has a property City . I want to give the user an option to create/update a Person along with its addresses, including adding and removing ones. So for displaying the addresses I simply call @Html.EditorFor(m => m.Addresses) , and the razor engine takes care of the collection using my custom template that resides in the EditorTemplates folder, generating foreach field a matching signature