In RadAutoCompleteBox i am able to select same item multiple times, how can i avoid selecting same item multiple times. That way it allows the user to duplicate items selected.

for example

I will select Apple. It goes to the box.Next again i will select apple.Then i get 2 apples on the box. Now apple is selected 2 times, this is a problem.

How to avoid this?

I have a web api project am working on and i want to use logger to log all my controller in web api to a file.

    public IActionResult GetAllDocumentTempates()
            var document = _doumentTemplate.GetLiteDocumentReportTemplates().ToList();
            var result = Mapper.Map<IEnumerable<LiteDocumentReportTemplateViewModel>>(document);
            return Ok(result);
        catch (Exception ex)
            String msgInnerExAndStackTrace = string.Format("{0}; Inner Ex: {1};  Stack Trace: {2}", ex.Message, ex.InnerException, ex.StackTrace);
            ExceptionLoggingService.Instance.WriteLog(string.Format("From frmDelivery.ConditionallyPrint():{0}", msgInnerExAndStackTrace));
            return BadRequest();

This is my ExceptionLoggingService.cs: This is the service that handle all the errors and logging to files for me

public class ExceptionLoggingService: ActionFilterAttribute
    // </ Singleton code
    // private fields
    private readonly FileStream _fileStream;
    private readonly StreamWriter _streamWriter;
    private static ExceptionLoggingService _instance;
    // public property
    public static ExceptionLoggingService Instance
            return _instance ?? (_instance = new ExceptionLoggingService());
    //private constructor
    private ExceptionLoggingService()
        _fileStream = File.OpenWrite(GetExecutionFolder() + "\\EasyAsFallingOffA.log");
        _streamWriter = new StreamWriter(_fileStream);
    // <!-- Singleton code

    public void WriteLog(string message)
        if (!HHSConsts.Logging) return;
        StringBuilder formattedMessage = new StringBuilder();
        formattedMessage.AppendLine("Date: " + DateTime.Now.ToString());
        formattedMessage.AppendLine("Message: " + message);
    private string GetExecutionFolder()
        return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);


This is my EasyAsFallingOffA.log file output

Date: 6/23/2018 12:02:24 PM Message: From frmDelivery.ConditionallyPrint():Object reference not set to an instance of an object.; Inner Ex: ; Stack Trace: at ProcessFlowManager.Domain.Helpers.ModelFactory.Create(CalendarActivity cal) in C:\Users\BABATUNDE\Documents\Visual Studio 2017\Projects\pcm-netcore\ProcessFlowManager.Domain\Helpers\ModelFactory.cs:line 1170 at ProcessFlowManager.Infrastructure.LogicImplementations.EfCalendarActivities.GetCalendarActivity(Int32 id) in C:\Users\BABATUNDE\Documents\Visual Studio 2017\Projects\pcm-netcore\ProcessFlowManager.Infrastructure\LogicImplementations\EfCalendarActivities.cs:line 54 at ProcessFlowManager.API.Controllers.CalendarController.GetAllGeneratedDcument(Int32 id) in C:\Users\BABATUNDE\Documents\Visual Studio 2017\Projects\pcm-netcore\ProcessFlowManager.API\Controllers\CalendarController.cs:line 79

Everything is working fine for all code above but all this code was implemented using tautology because i am repeating inside all my try and catch. I am new to AOP and am looking for a way to do this using AOP so i can just call it once inside my controller.

What are the alternatives, if any, to using inheritance when one wants to customize a webforms server control, either to add functionality or modify existing behavior?

Say I want to modify how databinding works for CheckboxList and RadioButtonList, to allow for reusing ListItem instances passed into it, instead of creating new ones internally during the databind phase (and losing Selected and Enabled properties in the process).

I could probably subclass the controls and override some databinding-specific method, but then I'd have to go to each of my pages and replace the controls one by one.

I would like to extend behavior of existing controls without having to subclass and substitute them. Is there such extension point in the framework? I see this as a similar mechanism to AJAX control extenders, but for the server-side somehow.

I am working with a WEB application in ASP .NET Core 2.0 where I have a custom ExceptionAttribute filter that inherits from ExceptionFilterAttribute.

How can I access the Model object passed to a action in POST call.

The mentioned method is passed a ExceptionContext but I could not find an easy and reliable way to get Model object from it and pass to ViewResult.

The filter I have, looks like the following:

public class ApiCallExceptionAttribute: ExceptionFilterAttribute
    private readonly IModelMetadataProvider _modelMetadataProvider;

    public ApiCallExceptionAttribute(
        IModelMetadataProvider modelMetadataProvider)
        _modelMetadataProvider = modelMetadataProvider;

    public override void OnException(ExceptionContext context)
        //how can i accesss model object here and pass to ViewResult
        result.ViewData = new ViewDataDictionary(_modelMetadataProvider,context.ModelState);

        context.Result = result;

and the controller looks like the following:

public async Task<IActionResult> Activation(ActivationViewModel model)
            //throw exception in controller content

I am creating a website powered by ASP.NET Core 2.1 and am attempting to use an SDK that was designed to be used on an AppDomain that is unique to one specific application instance and/or session; this means that the SDK has multiple APIs which expose data-storage members (fields, properties, etc.) that are static. In terms of using such an SDK with ASP.NET Core, this exposure structure seems to be an issue because the runtime only allocates one single AppDomain, on the server-side, for all of the sessions collectively, and thus possibly multiple separate users, to share. If I do not have access to the source of this SDK and/or it cannot be changed, for purposes related to platform-agnosticism, how do I use the SDK successfully without only being able to store the data for one session at a time. Here is a simplified version of what I am working with:

Sample API:

public sealed class User
    public static User ActiveUser { get; private set; } 

    public static int TotalLogCyclesThisSession { get; private set; } = 0

    public string Username { get; internal set; }

    private string Password { get; internal set; }

    public string Name { get; internal set; }

    public string AccessKey { get; }

    public User(string username, string password)
        /* Populate Instance Properties with Relevant Data */

        ActiveUser = this;

    public void Logout()
        /* Clear Data from Settable Instance Properties */

        ActiveUser = null;

Assume that the static variables are used elsewhere in the SDK as well.

So basically, if the API above were real, how would I use it in ASP.NET Core, so that every session would have it's own entire copy of the SDK to use, including session-specific static variables. If possible, I am looking for something like how it is possible to create a Blazor "Client" assembly, that has a new AppDomain for every session, and a "Server" assembly, though I understand that solution implemented by Blazor may not be applicable considering that it has a browser-local runtime active as well, whereas ASP.NET Core does not. Worst-case scenario, the API can be modified, but it still must be platform-agnostic to most extents. Thanks in advance for all help.

I'm trying to change report cell background color with case/switch conditions programmatically in the code before it loads (at runtime) , we don't want to use Format Object from report editor.

We need to color cells depending on their values and each row has different rules, for example: Image: Table + rules

We don't need to have static rules because they keep changing from time to time, the rules table is store in the database.

So we have to check the first cell in each row and depending on it we select the rule, so that we can get the colors from the rules table and assign them to the following cells in the same row.

How can we implement this functionality in C#?

Any help will be much appreciated.

Sometimes when a user clicks a hyperlink in email from me, the hyperlink is processed by ASP.NET twice instead of once.

  1. My .NET backend app sends an email to a user; email contains a hyperlink to my ASP.NET web site.
  2. Hyperlink's URL contains a unique number.
  3. When user clicks hyperlink, ASP.NET calls Page_Load() to process it, reads unique number from URL, and if my Session("unique") variable is not already set to unique number, then ASP.NET does some processing.

Normally, this process works every time. But sometimes Page_Load() is unexpectedly called a 2nd time (13 seconds after 1st time), and the Session("unique") variable is now empty. I'm surprised because I understood Session variables to last a lot longer than 13 seconds.

Backend .NET and ASP.NET on Visual Studio 2017 Pro. Server for backend and ASP.NET is Azure VM Windows Server 2012.

Here is the web form:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="">
<head runat="server">
<form id="form1" runat="server">
    <h2 id="first">Enter 1st Number<input type="text"  /></h2>
     <h2 id ="second">Enter 2nd Number<input type="text"  /></h2>
     <h2 id="third">Enter 3rd Number<input type="text"  /></h2>
    <button onclick="test()">Sublit</button>


    <p id="sum"></p>
<script src="JavaScript.js"></script>

And this is the javascript file:

function test()
    var num1 = parseInt(document.getElementById("first").value)
    var num2 = parseInt(document.getElementById("second").value)
    var num3 = parseInt(document.getElementById("third").value)

    var z = num1 + num2 + num3
    document.getElementById("sum").innerHTML = z

When I am pressing submit button sum of three no is not showing in page. It showws NAN once and after that it disappears. I started learning .net. Help me plz

i wont to upload malty images from FileUpload store theme in cookies and display the images in an update penal in the same time i get only the last photo updated to the update anal

and this the code behind in C# :

protected void addphoto_Click(object sender, EventArgs e)
        if (FileUpload1.HasFile )
            for (int i = 0; i < FileUpload1.PostedFiles.Count; i++)
                string vale = Guid.NewGuid().ToString() + ".png";
                string path = Server.MapPath("").Replace("user", "pimg") + "\\" + vale;
                b = "~/pimg/" + vale;
                //string test = "~/pimg/d13526f4-9713-48fa-bb5d-a37f27b0366e.png";
                if (Request.Cookies["aa"] == null)
                    Response.Cookies["aa"].Value = b;
                    Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + b;


if (Request.Cookies["aa"] != null)
            s = Convert.ToString(Request.Cookies["aa"].Value);
            string[] strarr = s.Split('|');
            foreach (var item in strarr)
                //string html = "<a class='btn btn-primary' style='padding: 10px; margin: 10px' href='deletitem?myid=" + item.ProdectID + "'>" + item.Name + "</a>" + "";
                Image img = new Image();
                img.ImageUrl = item.ToString();
                img.Height = 150;
                img.Width = 100;



After using command dotnet new mvc on a folder, than I tried to run it through VS Code and I got the following error:

It was not possible to find any compatible framework version.
The specified framework 'Microsoft.AspNetCore.App', version '2.1.0' was not found.

I saw that other people had already had this problem, but all the solutions I tried didn't work for me.

There is no document support for ASP.NET Core 2.

Please advise.

Purpose: To call the Google Calendar API on my Web App (ASP.NET Core 2.1)

I had a sql database and store in it lat&long attributes , I want to display markers on leaflet map according to these attributes // I am working on web application NOT a MVC project , any help ?

similar code :- -

I had this code from a MVC project and I could not rewrite the GetMap function to be suitable to asp application

I have a Razor Class Library which is used as a reference in the ASP.NET Core MVC project. The app is working fine. I removed the reference and used CompiledRazorAssemblyPart to add the dll to the application parts. Here is a sample code Loading Razor Class Libraries as plugins

The same route that worked when I used the RCL as a reference wont work anymore. Should I use any other settings to load the view?

I'm being asked to read in orders from json same format as

Here is a sample, note that some of the names have "-" in them for example: order-totals, order-products

"data": [
        "type": "orders",
        "attributes": {
            "customer_address_name": "testTestmann",
            "customer_address_company": "",
            "customer_address_zipcode": "9022",
            "customer_address_state": "uk",
        "relationships": {
            "customer": {
                "data": {
                    "type": "customers",
                    "id": "1"
            "order-status": {
                "data": {
                    "type": "order-status",
                    "id": "3"
            "order-totals": {
                "links": {
                    "related": "test2"
            "order-products": {
                "links": {
                    "related": "test1"
            "order-tags": {
                "links": {
                    "related": "test3"
            "order-status-history": {
                "links": {
                    "related": "test4"

Here is the code I use to deserialise:

Dim jsonOrders As String = jutils.GetJsonText(shopurl, shoptoken)
Dim obj = JsonConvert.DeserializeObject(Of MYS_Orders.MyStore_Orders)(jsonOrders)

This works fine on all attributes apart from the ones with names that include a "-" so of course OrderStatus does not deserialise.

This is what the objects look like :

Public Class OrderStatus
    Public Property data As Data
End Class

Public Class OrderTotals
    Public Property links As Links
End Class

Public Class OrderProducts
    Public Property links As Links
End Class

How can I name the objects with a "-" character so the deserialization works?

i am develop web software in MVC .. i want get information that are given on different websites like email addresses that are different companies email address ... then help me how can i get information that newly upload on different sites..

I am new to MVC and database. I found there are two ways to create a foreign key relation.

Approach #1:

public class Person
    public int Id { get; set; }
    public string Name { get; set; }
    public virtual List<Vehicle> vehicles { get; set; }

public class Vehicle
    public int Id { get; set; }
    public string lic_number { get; set; }

and the second way is:

public class Person
    public int Id { get; set; }
    public string Name { get; set; }

public class Vehicle
    public int Id { get; set; }
    public string lic_number { get; set; }
    public virtual Person person { get; set; }

Please tell me is there any difference in the two approaches.

Thanks for reading my question.

Im having these problem after installing on Visual Studio 2017

//Couldn't install Microsoft.VisualStudio.AspNet45.Feature

Package 'Microsoft.VisualStudio.AspNet45.Feature,version=15.7.27520.0' failed to install. Search URL;PackageAction=Install;ReturnCode=87 Details Command executed: "C:\Windows\system32\dism.exe" /online /quiet /norestart /Enable-Feature /FeatureName:"netfx4extended-aspnet45" /All /logPath:"C:\Users\lenovo\AppData\Local\Temp\dd_setup_20180624000214_074_Microsoft.VisualStudio.AspNet45.Feature.log" Return code: 87 Return code details: No file path specified. Log C:\Users\lenovo\AppData\Local\Temp\dd_setup_20180624000214_074_Microsoft.VisualStudio.AspNet45.Feature.log Impacted workloads ASP.NET and web development (Microsoft.VisualStudio.Workload.NetWeb,version=15.7.27625.0) Impacted components Advanced ASP.NET features (Microsoft.VisualStudio.Component.AspNet45,version=15.7.27625.0)

Let's say I have a view contains a product which any user can purchase and order. So in this view there is a button: 'Add to cart', description of the product, amount to order of the product. In this view, the user can select the amount via Html.TextBox, then the user can order it by clicking on 'Add to cart'. So I've been trying to code it but I'm not sure how correct the code is (The script is the problem)...

Notice that my controller function has two args: the product itself (there is a model for product) and the amount (integer). Well, I had no problems with the product, but once I started using also the amount, it became way more complicated.

Here is my code attached:

@*@model SurffingSite.Models.Products*@

@model List

    ViewBag.Title = "DisplayAllProducts";

Our products

    <div class="row">

        @foreach (var product in Model)

            <figure class="portfolio-item col-md-4 col-sm-6">
                <img src="~/images/@product.Picture" class="img-responsive" />
                <div class="product-details">
                    <h2 class="product-name">Products Name: @product.ProductName</h2>
                    <label>Category: @product.Category</label>
                    <div class="product-description">Description: @product.Description</div>
                    <div class="product-price">Price: @product.Price ₪</div>
                    <div class="form-group">
                        <label>Enter amount:</label>
                        <div class="col-md-10">
                            <input type="text" name="amounter" id="amounter" />

                        <a id="btn_add" href="" data-id ="@product" class="btn btn-info btn-lg" style="margin-left:60px">
                            <span class="glyphicon glyphicon-shopping-cart"></span> Add to cart
                        </a><br />

                        <a id="btn_more_info" href="@Url.Action("Index", "Home")" class="btn btn-info btn-lg" style="margin-left:60px">
                            <span class="glyphicon glyphicon-eye-open"></span> Read more


    $(".btn btn-info btn-lg").click(function(event)
        var url = '@Url.Action("AddToCart", "Cart", new {prod = "product", amount = "theamounter"})';
        url = url.replace("theamounter", $("#amounter").val());
        url = url.replace("product", $(this).data());
        window.location.href = url;

Here is the relevant controller method:

and here is my model for a product object:

I have the following function that finds a value within my table:

var a=3;
var b=4;
var c= $("#maingrid tr:eq(" + a + ") td:eq(" + b + ")").text();

This is working correctly. However, this is the final step of the process. I need a little help with the first couple of steps.

Table 1 looks like this:

     Team   Sport
     A      Football
     B      Soccer
     C      Baseball
     D      Lacrosse

Column 1 (Team) references the header rows and Column 2 (Sport) the first column in the following table (#maingrid):

Sport       A   B   C   D
Football    2   5   6   4
Lacrosse    3   4   1   0
Baseball    4   3   2   3
Soccer      1   4   3   2

So what I'm looking to do for example is take the value from the Team column and determine what the index number in the header row is. That index number then becomes var a.

Then take the value is the Sport column and work down the first row to become var b.

So var c for: A & Football would be 2. B & Soccer would be 4. C & Baseball would be 2 etc

Thanks for any help.

I'm a total newbie to this. How do I conditionally wrap this <Colosseum:PersonLabel... with <strong></strong>

        <Colosseum:PersonLabel ID="plPerson" runat="server" 
            PersonGUID='<%# Eval("person_guid") %>' 
            PersonName='<%# Eval("person_name") %>' 
            HasPhoto='<%# Eval("person_blob_id") != DBNull.Value %>'
            Restricted='<%# Eval("restricted") != DBNull.Value && Convert.ToBoolean(Eval("restricted")) %>'