This repo is a fork of next version of ASP.NET MVC. It's built to run on VS 2015, C#6 and the next runtime. Even if you could open it, you couldn't compile or run it. Visual Studio 2015 can create both vNext (5) and ASP.NET 4.5/4.6 projects. ASP.NET 5 projects...

Just figured out how to fix this. I basically need to include the following code <script src="~/Scripts/angular.js"></script> @Scripts.Render("~/bundles/myweb") in both the _Layout.cshtml and the index.cshtml (I only had it in Index.cshtml)...

The code below adds a lock into your service to keep other threads from executing the enclosed statements concurrently. public class CAImportService: ICAImportService { // OTHER METHODS AND SECTIONS REMOVED FOR CLARITY // Define static object for the lock public static readonly object _lock = new object(); /// <summary> ///...

Stilly! There is a refactor bug in VS that changes the routes as well! My default route was changed to the following and I had to rename name to id and everything is working fine! routes.MapRoute( name: "Default", url: "{controller}/{action}/{name}", defaults: new { controller = "Home", action = "Index", id...

Do you use the core CLR? The StreamWriter.Close method are not available in core CLR. You can use Dispose method replace. You also can use using statement: using (var writer = System.IO.File.CreateText("your_path")) { writer.WriteLine("text"); } ...

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...

You can use Html.Raw to output the unencoded data: <input id='myHiddenInput' type='hidden' value='@Html.Raw(ViewBag.Text)' /> Here is a link to dotnetfiddle. You can see the output in text field, but there is also a hidden field with the same unencoded information....

If you are looking to add an employee and their contact info on the same form, then you should use a View Model. Your View Model will be an amalgamation of the properties you need on both the Employee and Contact into one class. You will then implement your Employee...

the values like the error message, etc, are exactly what I need. As Stephan said in his comment, you don't have to go after getting the values for such data annotation attributes as it will be only and only duplication of work. If you really wanna encapsulate your form...

Why are you doing it that way,you can sort it by using Url.Action() and concatenating query string parameters this way: function patrListClick(PAT_ID) { window.location.href = '<%: Url.Action("PatrList", "Patr") %>?id='+PAT_ID; } ...

Loops in C# usually range from 0 to n-1, so be double-sure that starting at 1 is what you want. Other than that, the error results probably from the fact that Model only contains 5 or less elements, so accessing Model[5] results in an error, as the elements in Model...

When it receives a query such as /Validation/IsUserNameAvailable?userName=BOB&UserID=, MVC's model binder is confused because it does not know how to handle null/empty string params. Just change the param to an int and cast as necessary for your helper method: public JsonResult IsUserNameAvailable(string userName, int UserId) { var users = new...

You can use the edit event of the grid to hide some element from the popup window: $("#grid").kendoGrid({ edit: function(e) { e.container.find(".k-edit-label:first").hide(); e.container.find(".k-edit-field:first").hide(); } }); ...

If you don't specify a database name then the connection will use the default database for the user, in this case it's integrated security so it's your Windows login. As you likely have full system admin on the server the default database will be master so you will find all...

The main problem I see with your code is the first line in your TimeAgo() method: The DateTime dt object you pass to this method is local time for your clients, but then you use the server local time DateTime.Now to calculate the timespan. Pass the UTC timestamps you get...

Browser do not submit disabled control as they are read only. there is a workaround for your problem, you make the field readonly="readonly" instead of disabled="disabled"? A readonly field value will be submitted to the server while still being non-editable by the user. A SELECT tag is an exception though....

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...

If this is an AJAX call then the varialble initialization should be into the callback methods: Fakturi.fakturi.get({ id: $routeParams.id }, function (data) { $scope.faktura = data; }); Fakturi.komintenti.get({ id: $scope.faktura.KomintentID }, function (data) { $scope.komintent = data; }); According to this link, if you would like to get response immediately...

The best way is to create a composite wrapper: public class Wrapper { public ModelA A { get; set; } public ModelB B { get; set; } } Put Wrapper in the parameter list and mark that [FromBody]. You can't use that attribute more than once because all of the...

At this line var EmployeeKoViewModel.errors = ko.validation.group(self); you are trying to create a variable, but the syntax is like creating an object with a property which is of course invalid. In order to fix this you can initialize your object first: var EmployeeKoViewModel = {}; EmployeeKoViewModel.errors = ko.validation.group(self); if (!EmployeeKoViewModel.errors().length...

Found it. The Telerik support asked the right questions. The problem is quite simple: There is no editor template specified! There are (at least?) two ways to resolve this issue: 1. Specify the name of the editor template (e.g. .Editable(e => e.Editable(true).TemplateName("TemplateGeneratorRecord"))) and create the TemplateGeneratorRecord.cshtml in the EditorTemplates folder....

I don't think you can achieve this without using JavaScript. Here's something you could try (using jQuery for convenience): foreach (var item in Model) { <tr> <td data-iso="@item.someDate.ToString("o")"></td> </tr> } Afterwards, in document.ready just parse the date and set the locale in the td: $("document").ready(function () { $("td").each(function (index, elem)...

ViewBag is used when returning a view, not when redirecting to another action. Basically it doesn't persist across separate requests. Try using TempData instead: TempData["Tag"] = post.SelectedTag.ToString(); and in the view: <p><strong>Tag: @TempData["Tag"]</strong></p> ...

You are using a namespace, your full type name is Project.ViewModel.ViewModel (namespace is Project.ViewModel and class name is ViewModel) so use this using instead: @model Project.ViewModel.ViewModel ...

You need to move the data to the Request Body. In Fiddler it would be a separate input box (below the one in your screenshot). Your Headers for POST http://localhost:53660/api/pooltests become: User-Agent: Fiddler Host: localhost:53660 Content-Type: application/json Content-Length: 140 The headers Content-Type should be application/json and the Content-Length will be...

Because your use of new { @checked = item.Selected } means that your setting the checked property. checked="checked" or checked="true" or checked="anyValueWhatSoEver" all result in setting the checked attribute (although only the first one is valid html). As a result, as the DOM is loaded, the checked property of the...

You can change settings programmatically in NLog, but you can't serialize those settings to the XML, yet. What you can do: Save the setting to the <appSettings> when changed read the <appSettings> when needed. eg using System.Web.Configuration; using System.Configuration; Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); config.AppSettings.Settings["NlogConnectionString"].Value = "NewValue"; config.Save(ConfigurationSaveMode.Modified); Edit the connectionstring...

Autofac is nicely documented and it looks like you can find what you are after here. From what I can tell, if you have registered your updators with builder.RegisterType<LastActivityUpdator>(); builder.RegisterType<AnonymousUserLastActivityUpdator>(); then you should be able to register your services with builder.Register(c => new UserService(c.Resolve<LastActivityUpdator>())); builder.Register(c => new AnonymousUserService(c.Resolve<AnonymousUserLastActivityUpdator>())); or...

Update your KnowledgebaseController constructor to this: public KnowledgebaseController() { this.knowledgebases = new RepositoryBase<Knowledgebase>(db); } and remove abstract from the RepositoryBase<TEntity> class in order to make it instantiable. Please note: This is just a quick fix. To implement a much solid architecture which facilitates easy unit testing and loosely coupled classes,...

Change your Select to be a Where. Where uses a predicate to filter the data and return the same structure...just a subset. Select on the other hand changes the data structure to be whatever is evaluated in the provided function. In your case you are changing the structure to be...

Ensure term matches the case of the data. As all the data is loaded (.ToList() in the DAL), the .Where clause uses .Net comparison rather than SQL comparison: var vehicle = _service.GetAll().Where(c => c.Name.StartsWith(term, StringComparison.OrdinalIgnoreCase)... If, in the future, you want to change this to Contains, you can add an...

Is it possible that the incorrect result is actually on your machine and not Azure, and is because you are initialising ScheduledDateUtc as local time and not UTC? Consider these two lines of code: new DateTime(2015, 6, 1, 1, 1, 1).AddHours(5).ToUniversalTime().Dump(); new DateTime(2015, 6, 1, 1, 1, 1, DateTimeKind.Utc).AddHours(5).ToUniversalTime().Dump(); Here,...

There is no 'best' way to do this, but I'd suggest implementing your RESTful API using ASP.NET Web API and then consuming that with AngularJS on the front-end (using the $http service). It's a pretty neat way of communicating with your APIs without having to navigate away from the page,...

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...

If you must use a DI Container like Unity (instead of Pure DI), you should install it into your Composition Root, which is 'The site'. From there, you can reference the library projects and configure your container....

You are trying to save an object to the database with an explicit ID set by you while the database is expecting to generate that value itself. That is the Id_osoby property in your object is set to something other than 0 and it is not identified to the EF...

The 3rd parameter is the name of the controller. In your case you have a controller named HomeController so the 3rd parameter is "Home" (by convention, you omit the "Controller" suffix). In the case where the page the @Html.ActionLink() method is used has been generated by a method in HomeController,...

Html.Action will execute the action when view is loaded. Since you don't want this, You need load data asynchronously. You can store URL in custom data-* attribute to generate the URL use Url.Action. On click of the button load the partial view using .load() HTML <div class="modal-content" data-url='@Url.Action("GetPrintView", "Connector")'> </div>...

The only reason I see this to happen is because on POST action you want to use Model.Categories which is not persisted. You have to call again the GetCatgories() method in action Create. You get the NullReference exception because post.Category is null and you can't access a property of a...

The OrderBy function works by letting you return the property it should sort on, it will be called foreach item in the list. Instead of hardcoding it, we can use reflection instead: public ActionResult Index(AgentReportViewModel vm) { var b = Agent.GetAgents(); vm.Agents = vm.SortAscending ? b.OrderBy(x => GetValueByColumn(x, vm.SortByColumn)) :...

That's probably a good candidate for an EditorTemplate to be honest, that way you don't have any issues with prefixing: @Html.EditorFor(m => m.TechnologyFilters) Without using an editor template though, a technique you can use is to specify the prefix in your partial declaration within the ViewDataDictionary, by doing: Html.RenderPartial("_TechnologyFilters", Model.TechnologyFilters,...

I didn't manage to find the source of the problem, but closing all editor windows in VS seems to make it go away. If there are further lag spikes, restarting debugging might be also a good idea. Since I didn't see this problem in a new project, it might be...

error: function () { alert("EmptyResult returns."); debugger; $.post('@Url.Action("Delete2", "Customers")', { id: clickedId }); }, Result of a post does not refresh your page, so quick fix is to genrate an anchor with URL to controller action add id parameter and click on it or change window location with controller/action/clicked id....

Your local IP within your network is : System.Net.Dns.GetHostByName(Environment.MachineName).AddressList[0].ToString().Dump(); But you can be behind a firewall / router so/your organization must have unique IP which is measured by WhatsMyIp.com...

I suspect there is a difference in the local and remote configuration. I would check the environment variables for your web app, and compare them with your local app to see if there's any differences (i.e. CLR version, IIS version). You can check environment variables with the SCM site, which...

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...

Your missing an @symbol for the id attribute: Modify your script as well like this: ***EDIT some thing seems off about the radio buttons only one should be checked and they should have the same name ** you can use the # to denote and ID in Jquery by the...

The error you are seeing is likely due to you having multiple classes called Movie. I suggest you take a look at your namespaces and using statements to tidy this up. But, if you cannot change them, specify the type explicitly using the full namespace (I'm guessing which namespace to...

You can reference the open li using css class selector '.': $(".dropdown.open") this will give you the currently open dropdown. Explanation: 'CSS selectors' allow you to select elements using CSS syntax. For example: '#id' where the '#' indicates the following text is the id of the element. '.class' allows you...

You just want to make sure you don't pull anymore records out of the database than you need. As you can't use your ProviderViewModel constructor in LINQ to Entities you will have to retrieve the requested page yourself before creating your view model objects: public ActionResult Index(int? page) { List<ProviderViewModel>...

That exception means your model classes do not match with the database tables exactly. If you are in a database-first scenario (you design the database and then you make the classes) then you should add an "ADO.NET Entity Data Model" to your project and select the Code First from Database...

The system.webServer section in the Web.config file specifies settings for IIS 7.0 that are applied to the Web application. The system.WebServer is a child of the configuration section. For more information, see IIS 7.0: system.webServer Section Group (IIS Settings Schema). and <system.web> specifies the root element for the ASP.NET configuration...

You simply cannot prevent it from being called if there are multiple actions that are interacting with the filter. It will be called every single request. However, you could cache your last request for that user's identity and, if it is the same request, immediately return without continuing onto the...

If you want to delete a user, you need to get that user not creating a new instance of the User object. This needs to change: var deleteUserObj = new User {UserName = usernameToDelete}; To something like: var deleteUserObj = UserContext.LoadItemByUsername(usernameToDelete); Where LoadItemByUsername is a method that checks the db...

CSHTMLs are not binaries like controllers. Assuming the existing site is already set up to use Razor files then yes, you can drop them in there and they work as expected. If you have to change controller/ action method code to actually use this view you would have to recompile...

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...

You can create a editor template and pass the control list as model to the template and in the template you can iterate that list to generate the control. As i have shown below. 1->Create a class for Control Information. public class ControlInfo { public string ControlType { get; set;...

You can't do this: string.Contains(string array) Instead you have to rewrite that line of code to this: if (file == null || formats.Any(f => file.Contains(f))) And this can be shortened down to: if (file == null || formats.Any(file.Contains)) ...

This should do it using JsonConvert from newtonsoft.json <script> var coordinatesJson='@Html.Raw(JsonConvert.Serialize(Model.LoginCoordinates.ToArray())' var coordinates=JSON.parse(coordinatesJson); //you now have coordinates as javascript object var map; function InitializeMap() { // could loop over if needed for(var coords in coordinates) { // do something with coords } </script> ...