In your layout use Html.Action() or Html.RenderAction() to call a ChildActionOnly method that returns a partial view for LoginModel [ChildActionOnly] public ActionResult Login() { LoginModel model = // initialize the model you want to display in the Layout return PartialView(model); } and create a partial view that displays the links,...

You can't (well certainly SHOULDN'T) try to save directly to a user's filesytem from a web application. I suspect your null reference is somewhere in the Environment.SpecialFolders... object. It woud be better to return the file as a byte array to the response in your controller action. This way the...

Ok so ranquild's comment pushed me in the right direction. In my route config, I had the default route of routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); So that my homepage would still work on the url with...

First you need to get the decimal part of the number into a separate integer, then just call your number to words function twice something like this: double value = 125.23; int dollars = (int)value; int cents = (int)((value - (int)value) * 100); Console.WriteLine("{0} dollars and {1} cents", wordify(dollars), wordify(cents));...

You can customize your tables, your storage and your classes. The process is not straightforward but with a little bit of work you can do that. I've answered a similar question few days ago. You can find it here. You can find a project on github where I've tried to...

You need to use the underlying System.DirectoryServices.DirectoryEntry for the group: var groupEntry = (DirectoryEntry)group.GetUnderlyingObject(); (Note: according to MSDN GetUnderlyingObject() will return a DirectoryEntry, even though the return type is object.) From there you can get the member distinguished names: var memberDistinguishedNames = groupEntry.Properties["member"].Cast<string>(); The users from the other domain are...

After digging around in the source code, I've come to these conclusions. First, the purpose of unobtrusive is to wire up the rules and messages, defined as data- attributes on the form elements by MVC, to jQuery.validation. It's for configuring/wiring up validation, not a complete wrapper around it, so when...

If I know the amount of columns the model has, I can count the number of rows with a function and do this: var modelRows = exportQuery.Count()+1; string modelRange = "D1:F" + modelRows.ToString(); var modelTable = worksheet.Cells[modelRange]; Or, with more context. I verified that EPPlus will accept a string variable...

Your claim identity does not have ClaimTypes.NameIdentifier, you should add more into claim array: var claims = new List<Claim> { new Claim(ClaimTypes.Name, "Brock"), new Claim(ClaimTypes.Email, "[email protected]"), new Claim(ClaimTypes.NameIdentifier, "userId"), //should be userid }; To map the information to Claim for more corrective: ClaimTypes.Name => map to username ClaimTypes.NameIdentifier => map...

You radio button group is not inside the <form> tags so its value is not sent when the form is submitted. You need to move the radio buttons to inside the form (in the partial) and remove the hidden input for property ReportName. If this is not possible you could...

ko.observableArray does have a length property, but it is the property of the observableArray function itself, not of the array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length To get the length of the enclosed array, invoke observableArray then call length: self.object().length. For example in your code, change your alert to: alert(xhr + " " + status...

ViewBag is not faster. In both cases your creating a model of List<MyTable>. All the code you have show for creating your 'MyTable' model is pointless - your just creating a new collection containing duplicates from the existing collection. In the controller it just needs to be public ActionResult MyAction()...

I solved it by adding the filter after the initial query, checking if the e.PractitionerProfiles were null. var query = from e in _repository.GetAll<Entity>() from u in e.Users where (e.AuditQuestionGroupId != null ? e.AuditQuestionGroupId : 0) == this.LoggedInEntity.AuditQuestionGroupId from p in e.PractitionerProfiles.DefaultIfEmpty() select new { entity = e, user =...

Your Model.CurrencySymbol string can have some symbols that can be interpreted as format specifier symbols. You can use literal string delimiter ('string', "string") so your currency symbol string will be copied to the result. For example: column.PropertiesEdit.DisplayFormatString = string.Format("'{0}' #,0.00", Model.CurrencySymbol); //Here comes string delimiters: ↑ ↑ Also you can...

You can't do that I'm afraid, once you have sent the header for the download, you can't then send another set of headers to do the redirect. There is a technique mentioned in this blog post which you can alter to do a redirect when a cookie appears from the...

See this answer: When implementing your own IUserStore, are the "optional" interfaces on the class actually optional? You will need to trick or override the method you are trying to call in your store to implement one that does not use the "optional" lockout store. You may be unpleasantly surprised...

You need to model your collection items. You could go many to many or one to many. // many to many public class Interest { public int InterestId { get; set; } public string InterestDesc { get; set; } // field can't match class name } // one to many...

I would highly recommend you to create a new empty MVC 5 project, and move all your files there from old MVC 2 project. If you just try to update DLLs its very hard be sure if you updated all DLLs, proj file, nugets, or at least little bit more...

One option would be to use LINQ .Any(): var stringResults = db.Properties.Where(x => x.Address.Contains(id) || /* Other conditions || */ x.BayOptions.Any(g => g.Description.Contains(id))); Here, x.BayOptions.Any(g => g.Description.Contains(id)) will return true if any of the BayOptions values have a description which contains the ID....

I think that you need to create the DB in Azure from the Azure control panel. Once it is there, EF can use the connection string for Azure to add tables/data to an existing DB. Due to the configuration requirements of Azure DB, I haven't found any option but the...

I us a filter attribute to adorn the actions i wanted to expose to Simple Auth. I cant remember where i got this code from (probably stackoverflow i just don't have the link so i cant claim credit for it) public class BasicHttpAuthorizeAttribute : AuthorizeAttribute { protected override bool IsAuthorized(HttpActionContext...

Welcome to chasing the windmill of 100% test coverage :) You're right, there isn't a ton of value in unit testing a controller method which doesn't actually contain any logic. (Somewhere in the world, Uncle Bob just spilled his coffee.) There is some, though... By explicitly defining the expectations (in...

This article might help: Unfortunately this error is a little confusing because it says “nameidentifier or identityprovider” even though you may have one of the two. By default you need both. Anyway, if you’re not using ACS as your STS then the above error pretty much tells you what’s needed...

I solved this by examining all of the DbSet definitions. I had pared down the data model while also upgrading it. I had removed the Lookup model class but neglected to also remove the DbSet<Lookup> Lookups { get; set; } property. This resulted in the class being resolved as Microsoft.Ajax.Utilities.Lookup....

Do you have the Silverlight project added to your MVC project? If you don't you will need to go to your project that is your MVC, right click it and go to properties. Go to silverlight applications then add the project there too. Then try it with your current code...

I would simply recommend following the standard best practice of n-tier architecture and keeping logic related to things like querying a database in class libraries. MVC 6 is drastically different from previous versions, so there's no easy migration. You'll basically need to start a brand new project and move...

I'm not sure this is the best way of doing this, but I'll provide you with my solution to this problem. The main idea is to generate the link with all required parameters and format the href with javascript, like string.Format in c#. Generate the link: @Html.ActionLink("Link", "action", "controller", new...

Yes, they are. For example, a malicious user could send one of your employees and email containing a clear GIF with a URL that points at one of your intranet pages, or an employee could visit a web page that contains javascript that posts to one of your intranet pages....

Size and color are lazy loaded by default (virtual) so you need to eagerly load them: var products = context.Products.Include(p => p.Color).Include(p => p.Size).ToList(); https://msdn.microsoft.com/en-us/data/jj574232.aspx If your issue is with the drop downs, you will want to compose a viewmodel in your controller that has the list items, send that...

There's a handy documented guide by Rick Anderson which he wrote to upgrade from MVC4, the same applies to you with the exception of the fact that the "Old version" of DLLs he mentions will be different to the ones that you will have, but the outcome will still be...

I finally went with a mix of Wrapper classes and the methodology suggested by Raphaël Althaus: use Wrappers where some amount of sophistication may be required and use Raphaël's suggestion when simplicity will do. Here's how I am using wrappers (intentionally left out null checks): public class Entity1View1 { protected...

You need to change your $routeProvider.when url option, that will accept two parameter one would be albumType & other would be alubmName. You that you could get those values in your b1Ctrl using $routeParams service. Markup <li ng-repeat="album in albums"> <a ng-href="/albums/{{alubm.type}}/{{album.name}}">{{album.name}}</a> </li> Code when('/albums/:albumType/:albumName', { templateUrl: 'AlbumsList.html', controller: 'b1Ctrl'...

The default MVC5 template has a css rule in Site.css: input, select, textarea { max-width: 280px; } I usually remove this rule. It causes problems with Bootstrap v3 input group where the input box does not extend to its container's width....

MvcSiteMapProvider is driven by HTML helpers. Since I cannot reproduce the problem with v4.6.18 and MVC5, I suspect that you have not added one to your view. A typical case would be to add the menu HTML helper to your /Views/Shared/_Layout.cshtml page, as follows. <div class="navbar-collapse collapse"> @*<ul class="nav navbar-nav">...

To write server side code to be processed by razor engine, you have to prepend your statement with @. That will only work if that Javascript is embedded on the view. You can also do it with Javascript. Something like this should do the trick var urlParts = location.href.split('/'); var...