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...
ajax,asp.net-mvc,asp.net-ajax,asp.net-mvc-partialview,ajax.beginform
You need to do custom ajax post without HTML helper in this case. Create a normal form : <form id="frmEdit" class="form"> @Html.AntiForgeryToken() <div class="container"> @Html.ValidationSummary(true) //.... rest form component <button id="btnSubmit" type="submit">Submit</button> </div> </form> and do post by jquery similar like this <script> $( "form" ).on( "submit", function( event )...
asp.net,.net,asp.net-mvc,razor
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...
c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,razor
try this: @{ if (propiedadesFormularioDetalle != null) { <div class="panel panel-default"> <div class="panel-heading">Propiedades adicionales</div> <div class="panel-body"> <dl class="dl-horizontal"> foreach (KeyValuePair<string, string> propiedad in propiedadesFormularioDetalle) { <dt> Html.DisplayName(propiedad.Key) </dt> <dd> Html.DisplayFor(prop => propiedad.Value) </dd> } </dl> </div> } </div> } ...
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...
javascript,c#,jquery,html,asp.net-mvc
Add below line to top of the view page, then it works perfect. <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> ...
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 ...
It will count items in your navigation property: var Quantity=db.Jobs.Items.Count(); This means items per job...
Currently you are only Loading the Region. Change your Line in controller Action to var tLCSubRegion = db.TLCSubRegion.Include(s => s.ReName).Include(x => x.deliveryDay).ToList(); from var tLCSubRegion = db.TLCSubRegion.Include(s => s.ReName).ToList(); ...
jquery,asp.net-mvc,kendo-ui,kendo-grid
The first level of the dataSource is the groups. Then each group has a property called items which is actually the rows in the group. So try this: var grid = $("#grid").data("kendoGrid"); var dataView = grid.dataSource.view(); for (var i = 0; i < dataView.length; i++) { for ( var j...
c#,asp.net,asp.net-mvc,asp.net-mvc-4
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...
The response of IPInfoDB is a string like below: OK;;74.125.45.100;US;United States;California;Mountain View;94043;37.406;-122.079;-07:00 So we need to split into the various fields using C# codes below. string key = "Your API key"; string ip = "IP address to check"; string url = "http://api.ipinfodb.com/v3/ip-city/?key=" + key + "&ip=" + ip; HttpWebRequest webReq...
javascript,jquery,html,asp.net-mvc
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>...
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...
c#,asp.net-mvc,entity-framework
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>...
javascript,jquery,arrays,ajax,asp.net-mvc
You just need to change var t = $(this).html(); to var t = $(this).text();
Use a computed writable observable: var ViewModel = function() { var self = this; self.actualObservable = ko.observable('Y'); self.relatedObservable = ko.computed({ read: function() { return self.actualObservable() === 'Y'; }, write: function(x) { self.actualObservable(!!x ? 'Y' : 'N'); } }); }; ko.applyBindings(new ViewModel()); <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script> <input type="checkbox" data-bind="checked: relatedObservable"> = Checked<br />...
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...
jquery,asp.net-mvc,visual-studio-2013,asp.net-mvc-5
Your action method is expecting a string. Create a javascript object, give it the property "data" and stringify your data object to send along. Updated code: $.ajax({ type: 'post', dataType: 'json', url: 'approot\Test', data: { "json": JSON.stringify(data) }, success: function (json) { if (json) { alert('ok'); } else { alert('failed');...
In your casee you can achieve your goal by reflection. You can create simple extension method: public static void HtmlHelperExtensions { public static object GetPropertyValue(this HtmlHelper html, object src, string propName) { return src.GetType().GetProperty(propName).GetValue(src, null); } } then add proper namespace to namespaces node in web.config file: <add namespace="htmlhelperclassnamespace" />...
sql,asp.net,asp.net-mvc,database,entity-framework-6
Ideally what you want is a many-to-many relationship between your Shop and Product entities: public class Shop { public int ShopId {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;} } public class Product { public int ProductId {get; set;} public string Name {get; set;} public virtual ICollection<ShopProduct> ShopProducts {get; set;}...
sql,asp.net-mvc,signalr,service-broker
Unfortunately views are explicitly called out as invalid in Special Considerations When Using Query Notifications: The statement must reference a base table. The statement must not reference a view. Before you move the view definition up into the client app, you need to make sure the query in the view...
c#,sql-server,asp.net-mvc,entity-framework
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...
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...
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)...
c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
In your view, remove <input type="checkbox" value="" checked="checked"/> Allow Access Because of checked="checked", this will always print out a checked checkbox....
Add data-val and data-val-required attribute for Html.TextBox() as shown below. <script src="~/Scripts/jquery-1.10.2.min.js"></script> <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script> @using (Html.BeginForm("","")) { @Html.ValidationSummary() @Html.TextBox("bill_address", null, new { @class = "form-control valid", @data_val = "true", @data_val_required = "Billing Address is required" }) <input type="submit" value="Click"...
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....
c#,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-4,visual-studio-2012
Download this book "Microsoft ASP.NET 4 Step By Step" by George Shepherd.I found it very helpful.It will address all the issues you raised here.Thank you.
c#,asp.net,asp.net-mvc,asp.net-mvc-4
You need to add @Html.HiddenFor(m=>m.UserId) at the view so that the binder will bind it to the remote validation controller or otherwise there is no value to bind ...
c#,asp.net-mvc,linq,entity-framework,asp.net-mvc-3
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...
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)) ...
c#,.net,asp.net-mvc,dependency-injection,unity
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....
c#,asp.net-mvc,dependency-injection,singleton
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> ///...
c#,asp.net-mvc,dependency-injection,autofac
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...
asp.net-mvc,visual-studio-2013
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...
c#,asp.net-mvc,entity-framework,asp.net-mvc-3,razor
If you have no particular reason for using editor then replace @Html.Editor(valor) with @Html.TextBox("TextBoxName",valor) ...
c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor
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> ...
asp.net-mvc,entity-framework,null,edit,httppostedfilebase
Mark Image property as not modified: db.Entry(sach).State = EntityState.Modified; if (image == null) db.Entry(sach).Property(m => m.Image).IsModified = false; db.SaveChanges(); ...
c#,asp.net-mvc,enums,html-helper
You can write an extension method for Enums to return Display value of an Enum value: public static class DataAnnotationHelpers { public static string GetDisplayValue(this Enum instance) { var fieldInfo = instance.GetType().GetMember(instance.ToString()).Single(); var descriptionAttributes = fieldInfo.GetCustomAttributes(typeof(DisplayAttribute), false) as DisplayAttribute[]; if (descriptionAttributes == null) return instance.ToString(); return (descriptionAttributes.Length > 0) ?...
c#,asp.net,asp.net-mvc,c#-4.0,reporting-services
Use formatting: DateTime.Now.ToString("dddd, dd-MM-yy"); Output: Montag, 15-06-15 //Written day of week in your local culture. To edit the axis labeling, you can do it in your code-behind file: Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dddd, dd-MM-yy"; Or in your markup: <ChartAreas> <asp:ChartArea Name="ChartArea1"> <AxisX Title="Date" IsLabelAutoFit="True" TitleForeColor="#ff0000"> <LabelStyle Format="dddd, dd-MM-yy" /> <MajorGrid Enabled ="False"...
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...
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)...
asp.net-mvc,asp.net-mvc-2,asp.net-mvc-5
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...
c#,asp.net,asp.net-mvc,timezone,timezoneoffset
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....
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)) :...
c#,asp.net,asp.net-mvc,asp.net-web-api
@model allegrotest.Models.SearchArrayModel[] which is an array. So you could try @foreach (SearchArrayModel item in Model) { <h2>@item.AttribStructTable[1].AttribName</h2> <h3>@item.AttribStructTable[1].AttribValues[1]</h3> .. } or @for (int i = 0; i < Model.Length; ++i) { <h2>@Model[i].AttribStructTable[1].AttribName</h2> <h3>@Model[i].AttribStructTable[1].AttribValues[1]</h3> .. } ...
asp.net-mvc,visual-studio-2013
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...
c#,.net,asp.net-mvc,asp.net-mvc-5
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...
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,...
c#,asp.net-mvc,validation,html-helper
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...
javascript,asp.net-mvc,twitter-bootstrap
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...
asp.net-mvc,asp.net-mvc-5,asp.net-mvc-routing
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...
javascript,.net,asp.net-mvc,razor,icollection
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> ...
Since you're using DataType.Date, I believe your editor template should be called Date.cshtml. Your current setup would probably work if you omitted the [DataType] attribute.
c#,asp.net,asp.net-mvc,tinymce
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...
javascript,asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-mvc-routing
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...
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...
asp.net-mvc,kendo-ui,kendo-grid,kendo-asp.net-mvc
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(); } }); ...
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...
javascript,c#,html,asp.net-mvc
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; } ...
Try this out: public class ProjectViewModel { public string SelectedProjectKey { get; set; } // string may need to be int depending on what type ProjectKey is in your class public ICollection<Project> Projects { get; set; } } In the view: @Html.DropDownListFor((model => model.SelectedProjectKey), new SelectList(Model.Projects,"ProjectKey", "ProjectName")) Your controller action:...
asp.net-mvc,visual-studio-2013,asp.net-mvc-6
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...
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"); } ...
You are not passing a value for nServiceId to the controller. You are using this overload of Html.BeginForm() where the last parameter (new { name = "EnterData", id = "EnterData", nServiceId = nServiceId }) is adding nServiceId = "nServiceId" as a html attribute, not a route value (inspect the html...
c#,asp.net-mvc,entity-framework,asp.net-mvc-4,repository-pattern
Include is made to eagerly load navigation properties, meaning any property that is, in fact, another related entity. Since Nombre is a string, you do not need to include it: it is part of the entity that is returned from the database call. If Nombre were of a class representing...
asp.net-mvc,asp.net-mvc-4,razor,asp.net-mvc-5,claims-based-identity
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...
Per Discosultan in the comments: IEnumerable<int> interestIds = viewModel.ExistingInterests.Where(x => x.selected == true).Select(x => x.InterestId); ...
c#,jquery,asp.net-mvc,angularjs
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,...
c#,asp.net-mvc,interface,datacontext
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,...
javascript,asp.net,asp.net-mvc,asp.net-mvc-5,asp.net-routing
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...
c#,asp.net,asp.net-mvc,asp.net-mvc-3,asp.net-mvc-5
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...
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...
c#,asp.net,asp.net-mvc,entity-framework
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...
c#,asp.net-mvc,linq,asp.net-mvc-4
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...
c#,xml,asp.net-mvc,asp.net-mvc-4
Sourced: from this link The web.config (or app.config) is a great place to store custom strings: in web.config: <appSettings> <add key="message" value="Hello, World!" /> </appSettings> in cs: string str = ConfigurationSettings.AppSettings["message"].toString(); ...
The problem is you are not setting roleManager properly in webconfig. change your webconfig as below. <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="AspNetSqlRoleProvider" createPersistentCookie="false" maxCachedResults="25" /> ...
c#,asp.net-mvc,entity-framework
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...
asp.net-mvc,web-config,configuration-files,nlog
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...
c#,jquery,ajax,asp.net-mvc,razor
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....
c#,asp.net-mvc,entity-framework,entity-framework-6
In order to get "Code First from database" install the latest Entity Framework Tools for Visual Studio 2012/2013 (version 6.1.3)
RestSharp can do this for you automatically: public ActionResult GetImageOffer(string oid, string otr) { var client = new RestClient("valid url"); var request = new RestRequest("/Offer/OfferDirect", Method.POST); request.AddQueryParameter("oid", oid); request.AddQueryParameter("otr", otr); request.AddHeader("apikey", "secretkeyhere"); request.RequestFormat = DataFormat.Json; RestResponse<RootObject> response = client.Execute<RootObject>(request); return PartialView("_pImageOfferModel", response.Data); } ...
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...
You can use ViewContext.IsChildAction in view.
c#,asp.net,asp.net-mvc,authentication
It's because of your ViewBag's returnUrl sets null after postback, just simply put ViewBag.ReturnUrl = returnUrl; at the beginning of your HttpPost verb of Login action. ...
c#,asp.net,asp.net-mvc,asp.net-5,asp.net-mvc-6
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...
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...
c#,sql-server,asp.net-mvc,datetime,timezone
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,...
javascript,asp.net-mvc,angularjs,single-page-application
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...
c#,asp.net-mvc,listview,razor,kendo-ui
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....
javascript,asp.net-mvc,knockout.js
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...
c#,asp.net,asp.net-mvc,json.net
Does the assemblyBinding tag have proper xmlns schema? Check if the issue you are encountering is same as Assembly binding redirect does not work
c#,asp.net-mvc,razor,asp.net-mvc-5
Ok, the culprit was this: <ul class="list-inline text-center propertyRegionUL"> <li data-marketid="Miami-Dade" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() == "Miami-Dade" ? "active" : "")">Miami Dade</li> <li data-marketid="Fort-Lauderdale" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() == "Fort-Lauderdale" ? "active" : "")">Fort Lauderdale</li> <li data-marketid="West-Palm-Beach" class="regionLI @(ViewContext.RouteData.Values["id"].ToString() ==...
c#,asp.net,ajax,json,asp.net-mvc
The issue is with the way your JSON object is defined. It should have the single quotes for the prop names like this: {'org': 'string1', 'cat': 'string2', 'fileName': 'string3'} ...
asp.net,sql-server,asp.net-mvc
using System.Data.SqlClient; SqlConnection conn = new SqlConnection(<connectionstring>); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM table"; SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); And now you have a DataSet containing the results of your query. As for determining your , I suggest Connection Strings as...