I am using the "system.web.helpers.chart" and it is working (happen to be doing it in MVC but that shouldn't matter). But for the life of me, I can't seem to display the data like I want. All the examples seem to show what I'm looking for, but none of the code seems to back it up.

Take a simple data grid:

Fruit ........ Color ........ Quantity

Apples ....... Red .............. 5

Apples ....... Green ........... 3

Apples ....... Yellow ........... 2

Grapes ....... White ........... 20

Grapes ...... Red .............. 10

So all I'm looking for is like one of those "Column" charts, that should have the Fruit at the bottom. My Apples should have 3 columns grouped together (one for each color), and my Grapes should have 2 columns grouped together.

It's basically should look like ... with the exception that the fruit names be on the bottom, and the color be in the grid (or a legend)

enter image description here

Oh.. almost forgot.. basically here is my code...

SQL = "Select Fruit, Color, Quantity From Inventory"


.AddSeries( chartType: "Column", xValue: myDataTable.Rows, xField: "Fruit", yValues: myData.Rows, yFields: "Quantity" );

I'm trying to add a web service to my mvc project using web api. Upon project creation, I chose Mvc + Web Api for that.

However, I can't access the api controller, I keep getting this error:

        No HTTP resource was found that matches the request URI 'http://www.myapp.app/api/sms'.
        No type was found that matches the controller named 'sms'.

My global.asax:


My RouteConfig.cs:

public static void RegisterRoutes(RouteCollection routes)

        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }

My WebApiConfig.cs:

public static void Register(HttpConfiguration config)

        name: "DefaultApi",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }


My Api controller:

public class SmsController : ApiController
    private DbContext db = new DbContext();

    // GET: api/Sms
    public IQueryable<Sms> GetSms()
        return db.Sms;

Naturally I'm trying to access the api via http://www.myapp.app/api/sms.

I literally tried everything I could think of, and read about every related question on SO and other forums, but nothing helped me. I'm pretty sure it has to do with my application url, which is not the regular localhost:port, I changed it to www.myapp.app and it runs on port 80.

For that, I had to change the IIS bindings to look like *:80:www.myapp.app and also added this entry to the drivers/etc/hosts file: www.myapp.app.

At this point I'm pretty sure this is what is causing my problem.

Any ideas?

Application Insights says my requests are apparently being mapped correctly:

Application Insights saying there were request attempts

Also it shows that the following requests were mapped to this controller and action:

GET sms
GET Sms/GetSms
GET sms/getsms
GET sms/Index
GET /api/sms

I am trying to pass custom data to a Partial View using an instance of ViewDataDictionary

In prior versions the following code worked

@Html.Partial("PartialName", new ViewDataDictionary { { "key", "value" }})

but not in ASP.NET Core.

I have read the documentation but I cannot figure out how to create a working example.

I Have 10,000 record in my table on SqlServer DB when I bind it using SqlDataAdapter with GridView on Asp.net page with 3 textbox and button to filter the data I only get 266 record instead of 10,000 record when I use (%) to retrieve all my data Any help to solve the problem and my query is like that:

 (Full_name, 'لاتوجد بيانات') AS ASFull_name, COALESCE (Mother_Name,
 'لاتوجد بيانات') AS Mother_Name, COALESCE (Date_of_Birth, 'لاتوجد
 بيانات') AS Date_of_Birth, COALESCE (Province_of_birth, 'لاتوجد
 بيانات') AS Province_of_birth, COALESCE (Job, 'لاتوجد بيانات') AS Job
 FROM [Criminal Main Table]
    (Full_name LIKE N'%' + @Full_name +
 N'%' OR @Full_name IS NULL) AND (Mother_Name LIKE N'%' + @Mother_Name
 + N'%' OR @Mother_Name IS NULL) AND (Date_of_Birth LIKE N'%' +        
    @Date_of_Birth + N'%' OR @Date_of_Birth IS NULL)

And SqlDataAdapter Code Is:

" SelectCommand="SELECT COALESCE (IQCRM_NUM, 'لاتوجد بيانات') AS ASIQCRM_NUM, COALESCE (Full_name, 'لاتوجد بيانات') AS ASFull_name, COALESCE (Mother_Name, 'لاتوجد بيانات') AS Mother_Name, COALESCE (Date_of_Birth, 'لاتوجد بيانات') AS Date_of_Birth, COALESCE (Province_of_birth, 'لاتوجد بيانات') AS Province_of_birth, COALESCE (Job, 'لاتوجد بيانات') AS Job FROM [Criminal Main Table] WHERE (Full_name LIKE N'%' + @Full_name + N'%' OR @Full_name IS NULL) AND (Mother_Name LIKE N'%' + @Mother_Name + N'%' OR @Mother_Name IS NULL) AND (Date_of_Birth LIKE N'%' + @Date_of_Birth + N'%' OR @Date_of_Birth IS NULL)" OnSelecting="SqlDataSource1_Selecting" OnSelected="SqlDataSource1_Selected">


I am trying to pass a Base64 string generated from an image back to my controller. I have a hidden input field on my view that binds to a property on my view model. However, when I return the view model to my controller, the PhotoPath property shows as null.

enter image description here

Not sure why the data is not binding. I use Javascript to set the value of the PhotoPath input:

          if (this.files && this.files[0]){
              var reader = new FilerReader();
              reader.onload = function (e) {

This is my input field:

    @Html.HiddenFor(d => d.PhotoPath)

ViewModel property:

    public string PhotoPath { get; set; }

If I pass in a regular string in an EditorFor instance, it passes to the controller just fine. Not really sure what the problem is. Any help would be appreciated!

EDIT: This is contained inside a template of a Kendo ListView if that provides anymore context.

EDIT 2: This is the inspector after I set the photo:

enter image description here

var intervals = [];
        //Load each widget
        @foreach (var widget in Model.Widgets.OrderBy(p => p.OrderSequence).ThenBy(p => p.Title).ToList())
            @:loadWidget("@widget.WidgetId", "@widget.AjaxUrl");
            if (widget.RefreshSeconds > 0)
               @:setupWidgetAutoRefresh("@widget.WidgetId", "@widget.AjaxUrl", @widget.RefreshSeconds);

I need to store the return value from the setupWidgetAutoRefresh method into my Javascript intervals array. Is it possible for me to do so? How would I go about completing such a task?

Here is my code -

(function () {
        $(document).ready(function () {
            $('.switch-input').on('change', function () {
                var isChecked = $(this).is(':checked');
                var selectedData;
                var $switchLabel = $('.switch-label');
                if (isChecked) {
                    selectedData = $switchLabel.attr('data-on');
                } else {
                    selectedData = $switchLabel.attr('data-off');
                if (selectedData === 'ACTIVE') {
                    selectedData = 'A';
                } else {
                    selectedData = 'C';

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="switch">
                        <input class="switch-input" type="checkbox"/>
                        <span id ="tglInp" class="switch-label" data-on="CANCEL" data-off="ACTIVE"></span> <span class="switch-handle"></span>

I have this toggle switch that displays a filtered list based on the switch value : 'ACTIVE' or 'CANCEL'

This is on a Razor view. The grid that displays the list is in a partial view. But the toggle switch is on the full view.

The issue is when I return to this view, the grid is filtered based on the condition but the switch goes back to its default state. For example, if I go to the next view from Toggle switch state Cancel, when I return it should be still on Cancel but the toggle switch is on Active.

How do I do that. Any help would be highly appreciated! This is my first question, so if I made any mistakes, in posting, I apologize.

Thank you!

we are looking into integrating the Belgian EID (electronic identity cards) into our current asp.net web application. The purpose is to quickly read out someone's basic info (that's available without needing a pin code) and use it fill in a form.

But to be honest, I am totally lost in all the documentation that is out there. There seem to be numerous ways of doing it, but I can't seem to find any tutorials or something like that to explain how I do it. I know there's an applet, but since I've also read that Google Chrome is dropping support for applets (https://www.quora.com/Why-doesnt-Google-Chrome-support-Java-plugins-anymore) this doesn't seem the right way anymore.

Mind, I'm only looking to read out some basic public data (name, gender, ...) without the owner of the card having to enter the pin. There's nothing like real authentication going on.

Does anyone have any experience with this and can point me in the right direction?

My ASP.NET website uses OWIN and sometimes exception occurs during OWIN initialization (in Startup.Configuration method). How to show custom aspx page in this case? Or at least output some html to response.

I want to create grid view in Extjs and merge that grid to another grid-view and when i click on any record of grid-view then it will be open in new window.

So, How can i do that ??

I'm creating a system whereby it allows employees to log in day they work (eg, Monday/Tuesday...etc) and their time.

I have the "Employee" tables and a "Timesheet" table. Should the relationship be one to one or many to many or others?

Thanks for the help.


How to change the value of a control inside the header template of a DataList based on the value of a DataItem?

I cannot change the value in ListItemType.HeaderItem because I do not know what value to set it too until the ListItem is bound.


<asp:DataList ID="dl" runat="server" ShowHeader="true">
    <asp:Label ID="lbl" runat="server" Text="MyText" />



  Protected Sub dl_ItemDataBound(sender As Object, e As DataListItemEventArgs) Handles dl.ItemDataBound
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
      Dim Type As Integer = e.Item.DataItem("Type")

      If Type = 0 Then
        'Change lbl text in HeaderTemplate
      End If

    End If
  End Sub

below is xml file which I want to update (for example - change dateTime attribute in log element).

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<raml xmlns="raml21.xsd" version="2.1">
  <cmData id="3221225472" scope="all" type="plan">
      <log action="created" appInfo="Nokia BTS Site Manager" appVersion="FL16" dateTime="2016-09-23T17:59:59" user="BTSSM"/>

Here is my code:

filePath = openFileDialogXml.FileName;
XmlDocument document = new XmlDocument();
XmlElement node1 = document.SelectSingleNode("/header/log") as XmlElement;
if (node1 != null)
  node1.Attributes[3].Value = "test";

But, the problem is: node1 is always null. I now the problem cause this line in xml file:

raml xmlns="raml21.xsd" version="2.1"

I created a simple web application from visual studio Web Application(Net.Core) template with individual user account authorization.

Then, I enabled SSL in Project->MyProject Properties..., copied URL with https to App Url.

Finally, I added:

services.AddMvc(options =>
    options.Filters.Add(new RequireHttpsAttribute());

to Startup.

And it doesn't work! When I'm starting the application, it just simply turns off after a second, and nothing happens, no error, nothing!

What's wrong with SSL in Asp.Net Core, and how can I enable it correctly?

I'm building some software that has a WPF desktop app written in C# .NET, and some locally persisted storage using a SQLite database.

I've also created a SQL Server database hosted in Azure for persisting data in the cloud, and I'm working on a ASP.NETCore Web API that will sit between the database and any clients wanting to persist data on the server.

In the process, I've realized that a bunch of code like my database connection and helpers (or at least their interfaces), and the model interfaces that define what properties a certain object (e.g. a financial transaction) can be shared and re-used across both the desktop app and the Web API.

In the future, I'm planning to have mobile apps, and they will no doubt use much of the same logic and DAL code again. So my question is: what's the best way to design the architecture so as to future-proof myself now and avoid re-factoring my code a ton of times?

My plan right now is to create an API (class library) that will contain the business logic, DAL, and data model, and for this API to be referenced by the desktop app (which then becomes just a lightweight UI layer using MVVM) and references by the Web API's controllers. I'd have one implementation inside the API designed to talk to SQLite, and another to SQL Server.

The problem/confusion I see are that I'd end up having a class library on my desktop client that persists some data locally, but it's also calling a Web API to persist data, which would then call the same class library, just stored on the server, to tell the DAL to perform some operations on the server's database.

Something seems... off, about this setup. I'm trying to simplify things and aide maintainability, but it seems like I'm over-complicating things instead. Am I missing something?

The more I read, the more it seems like there are 10 ways to do anything and it's not really clear to me what the best way is.


In ASP.NET where and all we can refer the assembly reference in Project? for ex: generally we can refer the file in web.config file as like below

[In ASP X page we can refer assembly like below][1] 
  [1]: https://i.stack.imgur.com/JNFgM.png

  <%@ Register assembly="System.Web" namespace="System.JavaScript.Web" tagprefix="ex" %> 

Except this what are the other pages in which we can refer assembly as like above.

Im working on a Project Tool that lists all the Projects on the Dashboard. Now i want that when i click on the Project that the Data from my Database gets listet on the right site of it.

Problem 1


@foreach (var item in Model)

                      <td>Project Titel</td>

With this all the Database Data gets listet, but i just want the Data from one Project not from Project 1,2,3 listet.

How can i make that ?

Problem 2

How can i make that the Data gets listet when the User clicks on a Project. So if i click on Project 2 the data from Project to gets listet on the right site. See Screenshot -->

Screenshot of the front page

I am new to asp.net Mvc and I have a question probably a dumb one. I am working on my personal website and have a home page with a link to contact form. Here is how its working: my home controller index function returns view with my homepage and it also has a contact function which navigates to contact form ( with three input fields email, subject and message) on http get request when clicking the contact link. I also have a task sendemail which receives three parameters email, subject and message. My question is how can I get those values from the contact form pass them to sendemail task and execute it on post request on the contact form. I suspect that it probably is not a good idea to use mvc pattern to achieve this but the reason I am using Mvc is that eventually I will have other links on my page which will communicate with database and load info dynamically.

I have thought about putting them all in an array and sending them to the .NET app.

Is there a better way to do this?

I am using ASP.NET identity for creating users in web forms project. I tried to change AllowOnlyAlphanumericUsername property to false in order to allow č,ć,š,ž characters when user registers, but there seems to be problem in coding. Here is the register page code:

using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.Owin.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using System.Data.Entity;

public partial class Pages_Account_Register : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void btnPrijava_Click(object sender, EventArgs e)

        UserStore<IdentityUser> userStore = new UserStore<IdentityUser>();

        userStore.Context.Database.Connection.ConnectionString =

        UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);

        var validator = manager.UserValidator as UserValidator<IdentityUser>;
        if (validator != null) validator.AllowOnlyAlphanumericUserNames = false;

        IdentityUser user = new IdentityUser();

        user.UserName = txtKorisnicko.Text;

        if (txtPass.Text == txtPassOK.Text)

                // napravi user objekt

                IdentityResult result = manager.Create(user, txtPass.Text);

                if (result.Succeeded)

                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

                    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);




                    litStatus.Text = result.Errors.FirstOrDefault();
            catch (Exception ex)

                litStatus.Text = ex.Message.ToString();



            litStatus.Text = "Lozinke moraju biti identične !";

Here are two classes:

ApplicationUser class:

using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;

/// <summary>
/// Summary description for ApplicationUser
/// </summary>
public class ApplicationUser: IdentityUser
    public ApplicationUser()


    public ApplicationUser(string username) : base(username)


    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        return userIdentity;

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
        public ApplicationDbContext() : base("EcfSqlConnection", throwIfV1Schema: false)

        public static ApplicationDbContext Create()
            return new ApplicationDbContext();



using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ApplicationUserManager
/// </summary>
public class ApplicationUserManager: UserManager<ApplicationUser>
    public ApplicationUserManager(IUserStore<ApplicationUser> store)
                : base(store)

    public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
        var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationUser.ApplicationDbContext>()));
        // Configure validation logic for usernames
        manager.UserValidator = new UserValidator<ApplicationUser>(manager)
            AllowOnlyAlphanumericUserNames = false,
            RequireUniqueEmail = true

        // Configure validation logic for passwords
        manager.PasswordValidator = new PasswordValidator
            RequiredLength = 6,
            RequireNonLetterOrDigit = true,
            RequireDigit = true,
            RequireLowercase = true,
            RequireUppercase = true,

        // Configure user lockout defaults
        manager.UserLockoutEnabledByDefault = true;
        manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
        manager.MaxFailedAccessAttemptsBeforeLockout = 5;

        // Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user
        // You can write your own provider and plug it in here.
        manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider<ApplicationUser>
            MessageFormat = "Your security code is {0}"
        manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider<ApplicationUser>
            Subject = "Security Code",
            BodyFormat = "Your security code is {0}"

        var dataProtectionProvider = options.DataProtectionProvider;
        if (dataProtectionProvider != null)
            manager.UserTokenProvider =
                    new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
        return manager;


But there is no effect of the change of this property to false. I am still getting error: User name Krešo is invalid, can only contain letters or digits.

If you create a custom Exception that overrides the virtual property Message with something like this:

public class GrossException : Exception
    public GrossException() : base("Eww, gross") { }

public class BarfException : GrossException
    public override string Message { get; } = "BARF!!";

Then, when sending BarfException using JSON.NET through ASP.NET, the Message property will contain

"Eww, gross"

Instead of the overridden value. I believe this is related to the fact that Exception implements ISerializable, but since the Message property is virtual, should I not be allowed to override it like this and still have it work?

Is there a proper way to implement Exception and be able to override the Message property and still have it work?