Somehow my solution and project differ as to their Path/FullPath.

The Path property of my solution ("customerreportingnet") is:

C:\Users\cshannon\Documents\Visual Studio 2013\Projects\customerreportingnet\customerreportingnet.sln

The only project beneath that solution is a Website ("http://localhost/EMS/customerreportingnet/").

The website project's FullPath is this:

C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet

Why would the solution and project location differ?

Did I do something wrong in the setup? I downloaded the files from a .zip file, and extracted them to C:\EnhancedMonthlySalesReporting\

I then created a Virtual Directory in IIS, mapped it to C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet, giving it the Alias "EMS".

Then in VS I open the website (solution/project) this way:

File > Open Website...

and then I open IIS > EMS

When I do this, I do not see any files beneath the "project" - all that's visible in the Solution Explorer are just the solution and project names - no subfolders or files beneath them. But when I right-click the solution "customerreportingnet" and select "Open Web Site", then reply OK to "Open the Web site (this will close the current solution)" all is relatively well - I can right-click the project ("http://localhost/EMS/customerreportingnet/"), select View in Browser (Internet Explorer) and the site runs.

The only files in C:\Users\cshannon\Documents\Visual Studio 2013\Projects\customerreportingnet\ are:

customerreportingnet.sln customerreportingnet.v12.suo

C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet has those files and many more (as well as beaucoup folders).

Should I try to reset the solution Path to C:\EnhancedMonthlySalesReporting\customerreportingnet\customerreportingnet, or is that just an oddity, but not a problem?

If so, is that as easy as just changing that property value, or will that mess things up?

i am building some of my <option> tags in my js file. i debugged my file (in Chrome dev tool) and saw that everything is ok but when AJAX is finish my all page is refresh and all the DOM is restarting himself. I have no idea how to stop that .

Could you guys help me out ?

$("#clientCombo").on("change", function (event) {
    $.ajax({
        url: "/Account/GetBrands",
        data: { clientID: $("#clientCombo").val() },
        dataType: 'json',
        success: function (result) {
            if (result.error == undefined) {
                var brandList = result;
                var brandCombo = $('#brandCombo');
                var brandOption = $("<option value=\"none\">" + "someString+" + "</option>");
                for (var i = 0; i < brandList.length; i++) {
                    brandOption+=("<option value=\"" + brandList[i].brandID + ">" + brandList[i].brandName + "</option>");
                }
                brandCombo.html(brandOption); 
            }
        }
    });
});

cshtml :

 <select id="clientCombo" class="selectpicker">
                <option value="none">choose</option>
                @foreach (var clientItem in Model.clientList)
                {
                    <option value="@clientItem.ID">@clientItem.ClientName</option>
                }
            </select>

<div class="input-group">
             <label class="inputLabel">Brand</label>
             <select id="brandCombo" name="MotagNumber" class="selectpicker"></select>
         </div>

cs :

public string GetBrands(int? clientID)
{
    List<TableMotag> brandList = briefCont.GetBrands(clientID);

    if (brandList != null)
    {
        var brandInfo = brandList.Select(brandItem => new
        {
            brandName = brandItem.MotagName,
            brandID = brandItem.Num
        });

        return JsonConvert.SerializeObject(brandInfo);
    }
    return "error";
}

I've searched for answers to this, but cannot find even the slightest bit of definitive advice or information. I should note this is a ASP.Net 4.5.2 webforms application, running on IIS.

TL;DR - How does ASP.Net store large static collections, and are there best practices for searching for specific items?

I have a static collection of objects, that will only be changed during development. During runtime, the collection will never change, and will present the same objects to all users. I am planning to implement as follows:

public class Widget
{
    public Int32 Id { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public string ApiUrl { get; set; }
}

public static class AvailableWidgets
{
    public static List<Widget> LoadWidgets()
    {
        return new List<Widget>()
        {
            new Widget() { Id = 1, Title = "Foo", Description = ".", ApiUrl = "/api/Foo" },
            new Widget() { Id = 2, Title = "Bar", Description = "..", ApiUrl = "/api/Bar" }.
            new Widget() { Id = 3, Title = "FooBar", Description = "...", ApiUrl = "/api/FooBar" }
        };
    }
}

This list may grow to be very large (also there are many more properties, and additional lists as properties of the displayed class). I was going to move this data into SQL Server, but that brings overhead of its own, and also the CRUD code.

I have the following questions:

  1. How does ASP.Net store large static collections? Are these in-memory? What happens if the size of the collection is detrimental to the available memory (does it get placed onto the physical disk)?

  2. If I opt for the above approach, if I need to find a specific item in the collection, e.g.

    Widget widget1 = (from w in AvailableWidgets.LoadWidgets() where w.Id == 2352 select w).FirstOrDefault();

    ...is it bad practice to retrieve the whole collection first? Are there ways around this?

  3. Likewise, if I only need a specific property value from a single item, is this just awful for a large collection?

    string title = (from w in AvailableWidgets.LoadWidgets() where w.Id == 123 select w).FirstOrDefault().Title;

Any guidance from a seasoned listoholic would be very welcome.

I want to load a dropdown with numbers 1 - 20 and I have a javascript code to perform this. But Not sure how this function has to be called in the dropdown list.

$(document).ready(function(){
quantitydropdown();
})

function quantitydropdown()
{
  // Get reference to drop down
  var ddl = document.getElementById('quantitydropdownid');

  for (var i = 1; i < 21; i++) {
    var theOption = document.createElement("option");
    theOption.text = i;
    theOption.value = i;
    // If it is the first option, make it be selected
    i === 1 ? theOption.selected = "selected" :  "";
    ddl.options[i] = theOption;
  }
}
#quantitydropdownid { width:200px; }

#quantitydropdownid option:empty
{
  display:none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label for="quantitydropdown">Quantity</label>
<select id="quantitydropdownid" runat="server"></select>

So I am not sure how I should call this javascript function into the dropdown list. Need help!!

I have a List of reservations for bicicles and I need validation.. like when I am creating new reservation I Could not be able to create reservation for specific bike ID which has been already created. In The specific date_from and date_to of course.

for exmaple I have in list rezervations like:

ID 1 bikeID 2 Datefrom 19.5. dateto 20.5 ID 45 bikeID 5 Datefrom 18.5. dateto 19.5

so i cant't create reservation on bike with ID 2 from 18.5. to 19.5.

This is Actinon in controller of reservations:

        [Authorize(Roles = "zamestnanec")]
        public ActionResult Vytvor()
        {
            Kolobezka_dao kd = new Kolobezka_dao();
            IList<Kolobezka> k = kd.GetAll();
            ViewBag.IdKolobezka = k;

            return View();
        }

        [HttpPost] // pouze volana metodou post, nedokážu jí zavolat url adresou
        [Authorize(Roles = "zamestnanec")]
        public ActionResult Add(Rezervace rezervace, int idKolobezky)
        {
            if (ModelState.IsValid)
            {
                Kolobezka_dao kd = new Kolobezka_dao();
                Kolobezka k = kd.GetById(idKolobezky);

                rezervace.Rez_kolobezky = k;

                Rezervace_dao rd = new Rezervace_dao();

                rd.Create(rezervace);

                TempData["message-success"] = "Rezervace byla úspěšně přidaná";
            }
            else
            {
                return View("Vytvor");
            }
            return RedirectToAction("Index", rezervace);
        }

This is Rezervation class... Datum_od represent Date_from and Datum_do is Date_to:

public class Rezervace : IEntity1
{
    public virtual int Id { get; set; }

    public virtual Kolobezka Rez_kolobezky { get; set; }

    [Required(ErrorMessage = "Jméno je požadováno!")]
    public virtual string Jmeno { get; set; }

    [Required(ErrorMessage = "Příjmení je požadováno!")]
    public virtual string Prijmeni { get; set; }

    [Required(ErrorMessage = "Datum začátku rezervace je požadováno!")]
    public virtual DateTime Datum_od { get; set; }

    [Required(ErrorMessage = "Datum konce rezervace je požadováno!")]
    public virtual DateTime Datum_do { get; set; }

    public virtual string Popis { get; set; }
}

reservation is connected with bike ID as you can see... anf this is form to create new reservation:

<hr />
@using (Html.BeginForm("Add", "Rezervace", FormMethod.Post, new { @class = "form-horizontal" }))
{
    <div class="form-group">
        <label class="col-sm-2 control-label">ID koloběžky:</label>
        <div class="col-sm-2">
            @Html.DropDownList("idKolobezky", new SelectList(ViewBag.IdKolobezka, "Id", "Id"), new { @class = "form-control" })
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">Jméno:</label>
        <div class="col-sm-4">
            @Html.TextBoxFor(x => x.Jmeno, new { @class = "form-control" })
            @Html.ValidationMessageFor(x => x.Jmeno)
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">Příjmení:</label>
        <div class="col-sm-4">
            @Html.TextBoxFor(x => x.Prijmeni, new { @class = "form-control" })
            @Html.ValidationMessageFor(x => x.Prijmeni)
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">Datum od:</label>
        <div class="col-sm-4">
            @Html.TextBoxFor(x => x.Datum_od, new { @class = "form-control date-picker" })
            @Html.ValidationMessageFor(x => x.Datum_od)
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">Datum do:</label>
        <div class="col-sm-4">
            @Html.TextBoxFor(x => x.Datum_do, new { @class = "form-control date-picker" })
            @Html.ValidationMessageFor(x => x.Datum_do)
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">Popis:</label>
        <div class="col-sm-10">
            @Html.TextAreaFor(x => x.Popis, new { @class = "form-control formatedtext" })
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-success">Přidat</button>
        </div>
    </div>


}

I know it's kinda complicated, but if you have iny idea, and I hope you do, please let me know, thank you a lot.

I am working on the old application where many pages have resource file. Each file structure is(.aspx file, .aspx.vb file, and aspx.resx file).

Now I have added the new file by following MSDN resource.

https://msdn.microsoft.com/en-us/library/0hds5k93.aspx

In that file I can see the .aspx file, .aspx.vb file and the aspx.designer.vb file but I can't find the .aspx.resx file.

Can someone please help to create the resource file as existing files?

I have a WCF service that makes several TCP endpoints available and I'm looking at allowing a webHttpBinding as well.

So far it seems pretty straightforward to allow requests from a browser to such an enpoint, which returns a Stream of HTML text that the browser just displays.

Functionally, what is the difference between serving HTML pages from a WCF service vs from an asp.net service?

I'm still quite new at WCF, but I suspect it would not be very difficult to make a logical API available to a browser client that map to service methods that build up HTML via/without a templating engine.

I'd like to use Elmah to log errors from multiple customers' ASP.net Web Forms applications, to a central error database, each error logged with a unique application name.

I realise this can be easily set in the elmah.errorLog.applicationName attribute in web.config, but all our customers have standard web.config files, with the unique settings for each system in appSettings.config and connectionStrings.config files referenced by configSource or file attributes in web.config.

As the elmah sectionGroup in web.config doesn't allow the use of file or configSource, how can I set the applicationName for Elmah uniquely for each system?

I don't want to programmatically set the attribute in web.config, as it could be lost when the web.config is overwritten in the future.

I tried setting the ErrorLog.ApplicationName property in Global.asax.Application_Start(), like this, but the value I set was ignored.

Dim logger As Elmah.ErrorLog = Elmah.ErrorLog.GetDefault(Nothing)
logger.ApplicationName = "Testing 123"

Any advice would be much appreciated, as Elmah fits all our needs, we just need to be able to uniquely identify the errors it logs in the central error database.

I am trying to display a bar chart using chart.js.

The data JSON is in another file called barchart.txt from where I am reading it in my function. It looks like the format of data is incorrect because when I put alert on first line of function, even that doesn't work.

Both barchart.txt and Default.aspx are at same location.

barchart.txt

{
       labels: ["January", "February", "March", "April", "May", "June", "July"],
    datasets: [
    {
              label: "Dataset Testing",
        backgroundColor: [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(255, 206, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
            'rgba(153, 102, 255, 0.2)',
            'rgba(255, 159, 64, 0.2)'
        ],
        borderColor: [
        'rgba(255,99,132,1)',
        'rgba(54, 162, 235, 1)',
        'rgba(255, 206, 86, 1)',
        'rgba(75, 192, 192, 1)',
        'rgba(153, 102, 255, 1)',
        'rgba(255, 159, 64, 1)'
              ],
        borderWidth: 1,
        data: [65, 59, 80, 81, 56, 55, 40],
    }
       ]
}

Default.aspx

<html>
    <canvas id="mybarChart1"></canvas>
</html>

<script>
    $.getJSON("barchart.txt", function (data)
            {
                alert("here");
                var ctx = document.getElementById("mybarChart1");
                var myChart = new Chart(ctx, {
                    type: 'bar',
                    data: data,
                    options: {
                        scales: {
                            yAxes: [{
                                ticks: {
                                    beginAtZero: true
                                }
                            }]
                        }
                    }
                });
            });
</script>

We noticed that some very small webservice calls were taking much longer than we expected. We did some investigation and put some timers in place and we narrowed it down to creating an instance of our Entity Framework 6 DbContext. Not the query itself, just the creation of the context. I've since put some logging to see on average how long it actually takes to create an instance of our DbContext and it seems it was around 50ms.

After the application is warmed up context creation is not slow. After an app recycle it starts out at 2-4ms (which is what we see in our dev environments). Context creation seems to slow down over time. Over the next couple hours it will creep up to the 50-80ms range and level off.

Our context is a fairly large code-first context with around 300 entities - including some pretty complex relationships between some of the entities. We are running EF 6.1.3. We are doing a "one context per request", but for most of our web api calls it's only doing one or two queries. Creating a context taking 60+ms, and then execute a 1ms query is a bit dissatisfying. We have about 10k requests per minute, so we aren't a lightly used site.

I did take a memory dump to try and flesh out what's going on and here is the heap stats:

00007ffadddd1d60    70821      2266272 System.Reflection.Emit.GenericFieldInfo
00007ffae02e88a8    29885      2390800 System.Linq.Enumerable+WhereSelectListIterator`2[[NewRelic.Agent.Core.WireModels.MetricDataWireModel, NewRelic.Agent.Core],[System.Single, mscorlib]]
00007ffadda7c1a0     1462      2654992 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.Object, mscorlib],[System.Object, mscorlib]][]
00007ffadd4eccf8    83298      2715168 System.RuntimeType[]
00007ffadd4e37c8    24667      2762704 System.Reflection.Emit.DynamicMethod
00007ffadd573180    30013      3121352 System.Web.Caching.CacheEntry
00007ffadd2dc5b8    35089      3348512 System.String[]
00007ffadd6734b8    35233      3382368 System.RuntimeMethodInfoStub
00007ffadddbf0a0    24667      3749384 System.Reflection.Emit.DynamicILGenerator
00007ffae04491d8    67611      4327104 System.Data.Entity.Core.Metadata.Edm.MetadataProperty
00007ffadd4edaf0    57264      4581120 System.Signature
00007ffadd4dfa18   204161      4899864 System.RuntimeMethodHandle
00007ffadd4ee2c0    41900      5028000 System.Reflection.RuntimeParameterInfo
00007ffae0c9e990    21560      5346880 System.Data.SqlClient._SqlMetaData
00007ffae0442398    79504      5724288 System.Data.Entity.Core.Metadata.Edm.TypeUsage
00007ffadd432898    88807      8685476 System.Int32[]
00007ffadd433868     9985      9560880 System.Collections.Hashtable+bucket[]
00007ffadd4e3160    92105     10315760 System.Reflection.RuntimeMethodInfo
00007ffadd266668   493622     11846928 System.Object
00007ffadd2dc770    33965     16336068 System.Char[]
00007ffadd26bff8   121618     17335832 System.Object[]
00007ffadd2df8c0   168529     68677312 System.Byte[]
00007ffadd2d4d08   581057    127721734 System.String
0000019cf59e37d0   166894    143731666      Free
Total 5529765 objects
Fragmented blocks larger than 0.5 MB:
            Addr     Size      Followed by
0000019ef63f2140    2.9MB 0000019ef66cfb40 Free
0000019f36614dc8    2.8MB 0000019f368d6670 System.Data.Entity.Core.Query.InternalTrees.SimpleColumnMap[]
0000019f764817f8    0.8MB 0000019f76550768 Free
0000019fb63a9ca8    0.6MB 0000019fb644eb38 System.Data.Entity.Core.Common.Utils.Set`1[[System.Data.Entity.Core.Metadata.Edm.EntitySet, EntityFramework]]
000001a0f6449328    0.7MB 000001a0f64f9b48 System.String
000001a0f65e35e8    0.5MB 000001a0f666e2a0 System.Collections.Hashtable+bucket[]
000001a1764e8ae0    0.7MB 000001a17659d050 System.RuntimeMethodHandle
000001a3b6430fd8    0.8MB 000001a3b6501aa0 Free
000001a4f62c05c8    0.7MB 000001a4f636e8a8 Free
000001a6762e2300    0.6MB 000001a676372c38 System.String
000001a7761b5650    0.6MB 000001a776259598 System.String
000001a8763c4bc0    2.3MB 000001a8766083a8 System.String
000001a876686f48    1.4MB 000001a8767f9178 System.String
000001a9f62adc90    0.7MB 000001a9f63653c0 System.String
000001aa362b8220    0.6MB 000001aa36358798 Free

That seems like quite a bit of metadata and typeusage. What can we investigate further? I understand the cache used by EF is extensive to speed things up. Does more things in the cache, slow down the context creation? Is there a way to see exactly what's in that cache to flesh out any weird things in there? Does anyone know what specifically we can do to speed up context creation?

I'm currently working on getting a front-end connected to an API, and I'm sure I'm getting the following error due to a malformed body giving information not how the API wants.

jQuery error response in console.

This is how I used postman to get the data from the API:

Postman snip

In Postman, the body is simply:

{
"person" : "Jose Soto",
"connection":"Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=people;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}

and the response comes back fine. I'm sure I've miswritten the $.ajax() call wrong. Here's the call:

  $.ajax({
  'type' : 'POST',
  'url' : '/api/getpeople',
  'data' : {
    'person' : user,
    'connection' : app.connection
  },
    'success' : function(data){
      data.name = '${data.fName} ${data.lName}';
      app.userArray.push(data.name);
      app.ppl.push({
        'name' : data.name,

and so on....

I've dropdownlist in the each column header of the gridview that is populated dynamically in gridview_rowdatabound event. It is placed for the filtering functionality.

I'm able to get the drop down and list of items but the select index changed method is not getting fired

  GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  { 
    //some condition

                DropDownList ddl = new DropDownList();
                //some ddl properties
                 ddl.AutoPostBack = true;
                ddl.SelectedIndexChanged += new EventHandler (ddl_OnSelectedIndexChanged);
  }

I've also place a new event handler method but this event is not getting fired.

      private void ddl_OnSelectedIndexChanged(Object sender, EventArgs e)
    {
        string test = "reached on select Index changed";
    }

Any suggestion on how to get the upto this method on ddl change event ?

This question already has an answer here:

i have been trying to calculate the diffrence between two days using javascript.My problem is the variable seems to be undefined. i can solve this by using jquery datepicker, but was wondering if there were a solution for the html5 datepicker.

Razorhtml:

<div class="form-group" >
        @Html.LabelFor(model => model.Periode, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Periode,  new { htmlAttributes = new { @class = "form-control"} })
            @Html.ValidationMessageFor(model => model.Periode, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.EndDate, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.EndDate, new { htmlAttributes = new { @class = "form-control"} })
            @Html.ValidationMessageFor(model => model.EndDate, "", new { @class = "text-danger" })
        </div>
    </div>

my variables trying to get the value of the datepicker

            var dtfrom = $('Periode').val();
            var dtto = $('EndDate').val();

to sum up, i need to find the days between the 2 days, solved this using jquery datepicker, but wondering if there is a solution for using the Html5 datepicker.

I just want to ask on how to String Format Phone number and retain the leading zeros in razor and html The one I tried trimmed the leading zeroes

<text>@String.Format("{0:(###)###-####}", double.Parse(item.Phone))</text>

The output is always (42)123-4567 instead of (042)123-4567

Thanks!

My mvc view layout is null. how can i add script inside view.

@{
   Layout = null;
}

@section Scripts{
<script type="text/javascript">

    $(document).ready(function () {
        $('#txtChild1').on('change', function () {
             $("#C1Age1").show();
        });
    });

</script>
}

Error show

cannot resolve section 'Scripts'

I have already tried many solutions available on web as per my understanding in context to this question but being new in MVC I am still unable to find a solution. Kindly help.

I have a view which is the home page of the website named as "Index.cshtml" and is situated under the following path: WebsiteName/Areas/Website/Views/CypressHome/Index.cshtml

Secondly, I have a created a user trial form as partial view named as "_PartialHomeFormFreeTrial.cshtml" which is situated under the following path: WebsiteName/Areas/Website/Shared/_PartialHomeFormFreeTrial.cshtml. This form I have used inside my "Index.cshtml" as below:

<!--freetrialform-->
@Html.Partial("_PartialHomeFormFreeTrial")
<!--//freetrialform-->

Now, my partial page is posting data comprising of following elements:

@using (Html.BeginForm("Create", "Customer", FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <div>
    @Html.EditorFor(model => model.CustomerName, new { htmlAttributes = new { @class = "input__field input__field--kuro" } })
    @Html.ValidationMessageFor(model => model.CustomerName, "", new { @class = "text-danger" })

    ............
    other fields such as email, phone, date, etc..
    <input type="submit" id="" value="SEND REQUEST" />
    </div>
}

Now, I have created a controller named "CustomerController" which has the following code to save the data of the form as used as partial view in the main view "Index.cshtml":

public class CustomerController : Controller
{
    private WebsiteContext db = new WebsiteContext();

    // GET: Website/Customer
    public ActionResult Index()
    {
        return View();
    }

    // GET: Website/Customer/Create
    public ActionResult Create()
    {
        ViewBag.StatusPlanID = new SelectList(db.StatusPlans, "StatusPlanID", "Status");
        return View("Index");
    }

    // POST: Website/Customer/Create
    [HttpPost]
    public ActionResult Create([Bind(Include = "CustomerID,CustomerName,CustomerEmail,CustomerPhone,DateOfRegistration,StatusPlanID")] Customer customer)
    {
        if (ModelState.IsValid)
        {
            db.Customers.Add(customer);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        ViewBag.StatusPlanID = new SelectList(db.StatusPlans, "StatusPlanID", "Status", customer.StatusPlanID);
        return View(customer);
    }

}

I have tried many changes in my controller, return in the views and many other things but I am getting the same error always. Neither the validations are working nor the validated data is getting saved. The error is as below:

Server Error in '/' Application.

The view 'Create' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/Website/Views/Customer/Create.aspx
~/Areas/Website/Views/Customer/Create.ascx
~/Areas/Website/Views/Shared/Create.aspx
~/Areas/Website/Views/Shared/Create.ascx
~/Views/Customer/Create.aspx
~/Views/Customer/Create.ascx
~/Views/Shared/Create.aspx
~/Views/Shared/Create.ascx
~/Areas/Website/Views/Customer/Create.cshtml
~/Areas/Website/Views/Customer/Create.vbhtml
~/Areas/Website/Views/Shared/Create.cshtml
~/Areas/Website/Views/Shared/Create.vbhtml
~/Views/Customer/Create.cshtml
~/Views/Customer/Create.vbhtml
~/Views/Shared/Create.cshtml
~/Views/Shared/Create.vbhtml

And the url is changing as below: 1. On running the system initially: http://localhost:53872/ 2. On clicking on submit: http://localhost:53872/Areas/Website/Customer/Create along with the error as stated above.

For more information my WebsiteAreaRegistration.cs file contains the below code:

public class WebsiteAreaRegistration : AreaRegistration 
{
    public override string AreaName 
    {
        get 
        {
            return "Website";
        }
    }

    public override void RegisterArea(AreaRegistrationContext context) 
    {
        context.MapRoute(
            "Website_home",
            "",
            new { controller = "CypressHome", action = "Index", id = UrlParameter.Optional }
        );

        context.MapRoute(
            "Website_default",
            "Areas/Website/{controller}/{action}/{id}",
            new { controller = "CypressHome", action = "Index", id = UrlParameter.Optional }
        );
    }
}

Though I have understood the problem but unable to figure out. Kindly help.

the thing is i am getting the list of all users correctly but type mismatching between view and controller
return View(context.Users.ToList());

@model IEnumerable<BootstrapSite1.Models.Users>

@{
ViewBag.Title = "Index";
}
@foreach (var item in Model) {

}

<table class="prTable">
    <tr>
        <th>Exercise</th>
        <th>1</th>
        <th>2</th>
        <th>3</th>
        <th>4</th>
        <th>5</th>
        <th>6</th>
        <th>7</th>
        <th>8</th>
        <th>9</th>
        <th>10</th>
        <th>11</th>
        <th>12</th>
    </tr>

    @for (var i = 1; i <= 3; i++)
    {
        <tr class="prTableRow">
        @if (i == 1)
        {
            <td class="prExerVariNameTD">Squat</td>
        }
        else if (i == 2)
        {
            <td class="prExerVariNameTD">Benchpress</td>
        }
        else
        {
            <td class="prExerVariNameTD">Deadlift</td>
        }
        @for (var ii = 1; ii <= 12; ii++)
        {
            var getPR = "SELECT top 1 kg, rep, date FROM Test WHERE exerVariName LIKE '%Comp%' AND exercise = @0 AND rep = @1 order by kg desc";
            db.Execute(getPR, i, ii);

            foreach (var get in db.Query(getPR, i, ii))
            {
                DateTime Date = get.Date;
                var finalDate = Date.ToString("MMM d, yyyy");
                var weight = get.kg + "kg";
                var reps = "x " + get.rep;

                <td class="prTableCell" title="@finalDate">@weight @reps</td>
            }
        }
        </tr>

    }
</table>

So, in my database I have a bunch of data, based on training and each row has a exerise name, multiple can have the same, all rows also have weight data and amount of repetitions done on it. What this does is that it checks each exercise name and selects the highest weight done on that exercise name for 1 repetition, then 2 and so on till 12. So it will show me the best result I have done for each repetition for each exercise name in a table layout like in the picture below

enter image description here

however, there aren't always data for each repetition for all exercises is the database, so some numbers doesnt show as you can see in the picture, the squat row goes 1,2,3,5,6,10,12, so a few are missing, and I want each number to be under each corresponding number that is in the table header, so 5 will be located under 5 and so on, the way I would like to solve this is to put 0kg in the cells that has no data, so for example on the squat row, there is no data for number 4, I would like to put 0kg there which would push the 5 one forward one cell and it would end up under number 5, and so on for all so that they are all on the correct place.

So, for all repetition numbers that isn't in the database I would like to put 0. Does this even make sense?

EDIT: Database picture

enter image description here

I have a List (List) of Model objects which is presented in a view. I would like to add to that list without refreshing the page - therefore i thought Ajax is a great soloution. Im currently having a hard time getting it working.

My view is rendering a PartialView which contains the list.

Can somebody give me a hint how to pass a list to the controller and then back to the view without updating the whole page?

I hope my question makes sense.

/chris

EDIT:

I've been trying with JQuery. Looks like this:

<script>
$(document).ready(function () {
    $("#btnSave").click(function () {

        $.ajax(
            {
                type: "POST", //HTTP POST Method
                url: "/Video/Index", // Controller/View
                data: { //Passing data
                    testString: $("#txtArea").val(),
                    videoID: '@(Model.Video.iVideo_ID)',
                    taskID: document.getElementById('dropVal').value
                }
            }).success(function () {
                $("#proever").load("/Video/Index");
            });
    })
})

With this method i get to HttpPost method in my controller. And i pass the parameters into it succesfully.

[HttpPost]
    public ActionResult Index(CommentViewModel viewModel)
    {
        System.Diagnostics.Debug.WriteLine(viewModel.testString);
        System.Diagnostics.Debug.WriteLine(viewModel.videoID);
        System.Diagnostics.Debug.WriteLine(viewModel.taskID);



        viewModel.testString = "new text string";

        return View(viewModel);
    }

The problem is now that i can't get the updated viewmodel back to the view.. What am i doing wrong? In this example I don't update the list but just a test string to see if i can get it updated back to the view..

Im trying to format my HTML-table the way i want it, but can't seem to get it right. This is my code:

<tbody>
                        @{
                            int iterator = 0;
                            foreach (var kolumn in Model.Schema)
                            {
                                while (iterator < Model.AS_SC_OP.Count())
                                {
                                    foreach (var opKolumn in Model.AS_SC_OP)
                                    {
                                        <tr>
                                            <td>
                                                @Html.DisplayFor(modelKolumn => opKolumn)
                                            </td>
                                        </tr>
                                        iterator++;
                                    }
                                }
                                <tr>
                                    <td>
                                        @Html.DisplayFor(modelKolumn => kolumn.AS_SC_KM)
                                    </td>
                                </tr>
                            }
                        }
                    </tbody>

What happens here is that data from

@Html.DisplayFor(modelKolumn => opKolumn)

and the data from

@Html.DisplayFor(modelKolumn => kolumn.AS_SC_KM)

gets on the same column. The first one. I want the first one in the first column, and the second one in the second column.

Here is a picture of what i am trying to do.

enter image description here

This is what it looks like right now.

enter image description here

Any ideas what i have done wrong?

I'm working on signalR project and I want to scale out signalr using redis by following the steps in the official documentation.The problem is that when I use only signalr the application works fine: signalr client is sending three requests to the server – negotiate, connect and start but when adding this line: " hubConfiguration.Resolver.UseRedis(new RedisScaleoutConfiguration("localhost", 6379, string.Empty, "MyApp"))" in my startup the signalr client sends only negociate and connect with response status code:200 but don't send the start request. My statrtup looks as the following:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/signalr", map =>
        {
            map.UseCors(CorsOptions.AllowAll);
            HubConfiguration hubConfiguration = new HubConfiguration();
            hubConfiguration.EnableDetailedErrors = true;
            hubConfiguration.EnableJavaScriptProxies = false;
            hubConfiguration.EnableJSONP = true;
            GlobalHost.Configuration.TransportConnectTimeout = 
            TimeSpan.FromSeconds(10);
            hubConfiguration.Resolver.UseRedis(new 
            RedisScaleoutConfiguration("localhost", 6379, string.Empty, 
            "TrainApp"));
            map.RunSignalR(hubConfiguration);
        });
    }
}