Imagine two modules. 1) Survey 2) Client

When user enters a survey module on the client (IOS device) a new survey is created in the database with a unique ID which the db generates. To do that on the backend we use the SurveyController which receives a simple Survey object via a POST request from the client with just a datesatmp. Looks like this:

 [HttpPost("/api/survey")]
 public IActionResult CreateSurvey([FromBody] SurveyResource surveyResource)
 {

        var entity = mapper.Map<SurveyResource, Survey>(surveyResource);

        repository.Add(entity);
        unitOfWork.Complete();

        var resource = mapper.Map<Survey, SurveyResource>(entity);


        return Ok(resource);
 }

Now, the user is inside the app and has already got a unique survey ID. We now want to Navigate the user into the client module where he/she has to fill out some survey data that has to do with the client.

After the user fills out the client data we kick off an API call to the db when he is done with a POST request to a ClientController. We pass the client info, the db creates a unique client id but we also want to write this client id to the survey table. The client controller part looks like this:

    //create new client
    [HttpPost("/api/client")]
    public IActionResult CreateClient([FromBody] ClientResource clientResource)
    {

        var entity = mapper.Map<ClientResource, Client>(clientResource);

        repository.Add(entity);
        unitOfWork.Complete();

        var resource = mapper.Map<Client, ClientResource>(entity);

        var clientId = resource.Id;

        return Ok(resource);
    }

I'm in doubt on the best practice to proceed with updating the survey table with a client ID. I am thinking about a few options but really can't choose one. I would be really helpful if anyone can suggest some reading or some personal best practices on this matter. So here are my choices:

Choice 1

1) Pass survey id to client controller from client 2) Update survey table with client id after we get a response from a post request that was made to create a new client because that is where we will get the unique client id from. 3) Do everything in one controller (sounds dirty)

Choice 2 1) Create new client entity and get response clientID to the client application. 2) Pass a pur request from client directly to survey controlller with clientID and surveyID from the client.

Choice 2 sounds like a cleaner approach to me and looks like I have relized it on the fly whilst writing the question. However there are still two API calls and I can't think of any way to combine this into a single db ping.

Cheers.

Ok, so I'm not really sure where to put this.

I support a plant that runs a webpage to make changes to the process.

It runs on .net framework 4.0

For some reason (they claim they have done nothing) it reverted everything in IIS to v2.0 (this has happened twice)

What could possibly do this / how could I find out what did this...

my question is about how to go about updating data in a ASP.NET listview using a stored procedure. I'm getting an error message whenever I try to update any data in my listview stating that my stored procedure has too many arguments specified. I've looked through all of my code and all of my arguments seem to match up with my stored procedure so I think it might have to do with how I created the listview (just dragging and dropping it in design view using visual studio 2015) or it's something wrong with my stored procedure. I've been stuck on this issue for about a day now and I feel like I'm missing something real simple here but can't quite put my finger on it. If anyone could help my out I would greatly appreciate it. This app I'm working on uses vb.net as it's back end (not a choice of mine) and used ASP.NET web forms. Below is the code for the page I'm working on.

ASP.NET Page (Might not work properly since it uses a master page and some other external resources)

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/MasterPages/MasterPage.Master" CodeBehind="CodeManagement.aspx.vb" Inherits="OcasNS.CodeManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderInHead" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CPH1_DontUseInAContentPageItsJustForTheseJavaScriptFiles" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <p>Course Code:<asp:TextBox ID="TextBox1" runat="server" Height="18px"></asp:TextBox>
</p>
    &nbsp;<br />
    <p>Course Title:<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
    </p>
&nbsp;<br />
    <p>Class/Group:<asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>
    </p>
    <p>Career Tech Course Type:
        <asp:DropDownList ID="DropDownList2" runat="server">
        </asp:DropDownList>
    </p>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OKECSTestConnectionString %>" SelectCommand="spCodeManagementLookup" SelectCommandType="StoredProcedure" UpdateCommand="spCodeManagementUpdate" UpdateCommandType="StoredProcedure">
        <UpdateParameters>
            <asp:Parameter Name="ClassGroupID" Type="Int32" />
            <asp:Parameter Name="CourseDescription" Type="String" />
            <asp:Parameter Name="ClassSubjectCode" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
&nbsp;<asp:ListView ID="ListView1" runat="server" DataKeyNames="ClassGroupID" DataSourceID="SqlDataSource1">
        <AlternatingItemTemplate>
            <tr style="background-color:#FFF8DC;">
                <td>
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                </td>
                <td>
                    <asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
                </td>
                <td>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </td>
                <td>
                    <asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
                </td>
            </tr>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <tr style="background-color:#008A8C;color: #FFFFFF;">
                <td>
                    <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
                </td>
                <td>
                    <asp:Label ID="ClassGroupIDLabel1" runat="server" Text='<%# Eval("ClassGroupID") %>' />
                </td>
                <td>
                    <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                </td>
                <td>
                    <asp:TextBox ID="ClassSubjectCodeTextBox" runat="server" Text='<%# Bind("ClassSubjectCode") %>' />
                </td>
            </tr>
        </EditItemTemplate>
        <EmptyDataTemplate>
            <table runat="server" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
                <tr>
                    <td>No data was returned.</td>
                </tr>
            </table>
        </EmptyDataTemplate>
        <InsertItemTemplate>
            <tr style="">
                <td>
                    <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                    <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
                </td>
                <td>&nbsp;</td>
                <td>
                    <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                </td>
                <td>
                    <asp:TextBox ID="ClassSubjectCodeTextBox" runat="server" Text='<%# Bind("ClassSubjectCode") %>' />
                </td>
            </tr>
        </InsertItemTemplate>
        <ItemTemplate>
            <tr style="background-color:#DCDCDC;color: #000000;">
                <td>
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                </td>
                <td>
                    <asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
                </td>
                <td>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </td>
                <td>
                    <asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
                </td>
            </tr>
        </ItemTemplate>
        <LayoutTemplate>
            <table runat="server">
                <tr runat="server">
                    <td runat="server">
                        <table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
                            <tr runat="server" style="background-color:#DCDCDC;color: #000000;">
                                <th runat="server"></th>
                                <th runat="server">ClassGroupID</th>
                                <th runat="server">Description</th>
                                <th runat="server">ClassSubjectCode</th>
                            </tr>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr runat="server">
                    <td runat="server" style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                        <asp:DataPager ID="DataPager1" runat="server">
                            <Fields>
                                <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
                            </Fields>
                        </asp:DataPager>
                    </td>
                </tr>
            </table>
        </LayoutTemplate>
        <SelectedItemTemplate>
            <tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
                <td>
                    <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                </td>
                <td>
                    <asp:Label ID="ClassGroupIDLabel" runat="server" Text='<%# Eval("ClassGroupID") %>' />
                </td>
                <td>
                    <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                </td>
                <td>
                    <asp:Label ID="ClassSubjectCodeLabel" runat="server" Text='<%# Eval("ClassSubjectCode") %>' />
                </td>
            </tr>
        </SelectedItemTemplate>
    </asp:ListView>
    <br />
    &nbsp;<asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowEditButton="True" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <br />
    <br /> 

    <button type="button">Save</button>
    <button type="button">Cancel</button>
    <button type="button">Export To Excel</button>

</asp:Content>

Update Stored Procedure (The one causing the error)

@ClassGroupID INT,
@CourseDescription VARCHAR(100),
@ClassSubjectCode VARCHAR(20)

UPDATE [dbo].[tb_oecs_CodeClassGroup]
    SET [Description] = @CourseDescription
    , [ClassSubjectCode] = @ClassSubjectCode
WHERE ClassGroupID = @ClassGroupID    

Lookup Stored Procedure (This loads the data into the Listview)

SELECT DISTINCT
    g.ClassGroupID
   ,g.Description
   ,g.ClassSubjectCode
FROM tb_oecs_CodeClassGroup g
JOIN tb_oecs_CodeClass c
    ON g.ClassGroupID = c.ClassGroupID
ORDER BY g.ClassGroupID

I am having trouble doing config transform, adding app settings on nuget package install where element appSetting may or may not exist.

What I want to happen:

  • appSetting element does not exist
    • Insert appSetting element and its children
  • appSetting element exist
    • Insert children if missing

I only get one or the other to work, but not both occasions.

web.config.install.xdt

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings xdt:Transform="InsertIfMissing" >
    <add key="Swagger.Contact.Name" value="Some Name" xdt:Transform="InsertIfMissing" />
    <add key="Swagger.Contact.Email" value="some@email.address" xdt:Transform="InsertIfMissing" />
  </appSettings>
</configuration>

Example 1

web.config BEFORE

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
    <customErrors mode="Off" />
  </system.web>
</configuration>

appSettings element not present before transformation.

web.config AFTER

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
    <customErrors mode="Off" />
  </system.web>
  <appSettings>
    <add key="Swagger.Contact.Name" value="Some Name" />
    <add key="Swagger.Contact.Email" value="some@email.address" />
  </appSettings>
</configuration>

Example 2

web.config BEFORE

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
    <customErrors mode="Off" />
  </system.web>
  <appSettings>
    <add key="Other.Key" value="With Some Value" />
  </appSettings>
</configuration>

appSettings element present before transformation.

web.config AFTER

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="51200" />
    <customErrors mode="Off" />
  </system.web>
  <appSettings>
    <add key="Other.Key" value="With Some Value" />
  </appSettings>
</configuration>

Nothing happens in example 2 as the appSettings element already exist, I would like it to still evaluate its child elements and insert those if they do not exist, but it seems they are just ignored. Is there any other value for the attribute xdt:Transform I can use, or any other hacks to work around this issue?

After a installing the creators update I ended up getting this error:

Specified argument was out of the range of valid values. Parameter name: site error. 

I was able to repair IIS by downloading IIS 10 from Microsoft. Unfortunately, in addition to breaking IIS the Creators update borked my user permissions on my dev folders and git was unable to add and remove folders. For the life of me I couldn't figure out how to fix that. So, I decided to roll windows back.

Guess what? It broke IIS again. This time though the IIS 10 installer would not let me repair IIS, I couldn't repair it from Add/Remove programs, and I can't uninstall it to start over. I tried uninstalling it from the VS2017 installer and reinstalling it that also did not work.

I have a project that I want to use for the list of clients in the row sub-row, for example, see the table below. Shopping details are displayed in the list below when the user clicks the details button How can I do this all the way؟

+details|Rowno|Customer |Customer Name|DateReg|TimeReg|TypeRec|Dsc|User Reg

+    |  1  | 2095    |     A     | 02/20 |20:10|   all |...| 1001
+    |  2  | 2095    |     B     | 03/10 |19:10|   all |...| 1001
+    |  3  | 2095    |     C     | 04/31 |20:23|   all |...| 1001
-    |  4  | 2095    |     D     | 04/31 |20:20|   all |...| 1001
        |  1  | T-shirt  | 01/05 | 10:10:01 | cloth | by from shop 1
        |  2  | Socks    | 01/05 | 10:10:01 | cloth | by from shop 4
+    |  5  | 2095    |     Ali     | 02/20 |20:10:2|   all |...| 1001

    public  JsonResult GetFailsPcode(int pcode)
    {
        var f = new FailsRepository(); 
        var JsonData = new
        {
            data = f.SelectJoined(pcode)
        };
        return Json(JsonData, JsonRequestBehavior.AllowGet);
    }
    public async Task<ActionResult> GetFails()
    {
        var f = new FailsRepository();
        var JsonData = new
        {
            data = f.SelectJoined()
     };
        return Json(JsonData, JsonRequestBehavior.AllowGet);
    }

View code

<table class="table table-striped table-hover table-bordered" id="failstable">
                                <thead>
                                    <tr>
                                        <th></th>
                                        <th>
                                            rowno
                                        </th>
                                        <th>
                                            customer no
                                        </th>
                                        <th>
                                            customer name
                                        </th>
                                        <th>
                                            Date Reg
                                        </th>
                                        <th>
                                            Time Reg
                                        </th>
                                        <th>
                                            Type req
                                        </th>
                                        <th>
                                            Dsc
                                        </th>
                                        <th>
                                            Tel
                                        </th>
                                        <th>
                                            User Reg
                                        </th>
                                    </tr>
                                </thead>
                                <tbody></tbody>

                            </table>

and this is my jquery code

       $(document).ready(function ()
    {
        function format(d) {
            g = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
            $.ajax({
                type: 'GET',
                url: '/Home/GetFailsPcode',
                dataType: 'json',
                data:{pcode:d.serial},
                success: function (data) {
                    var objData = data;
                    console.log(objData);
                    for (var i = 0; i < data.length; i++) {
                        $.each(data[i], function (index, items) {
                            console.log(items.label);
                            var label = items.label;
                            var value = items.value;
                            console.log(items.value);
                            g+=('<tr><td>' + label + '</td>' + '<td>' + value + '</td></tr>');
                        });
                    }
                }
            });
            g += '</table>';
            return g;
            // `d` is the original data object for the row

        }
        var dt = $("#failstable").DataTable({
                         order: [ 2, 'desc' ],
                         "ajax": "/Home/GetFails",
                        "columns": [
                        {
                            "className":      'details-control',
                            "orderable":      false,
                            "data":           null,
                            "defaultContent": ''
                        },
                        {
                            data: "serial", width: "5%","className": "dt-center",
                            render: function (data, type, row, meta)
                            {
                                return meta.row  + 1;
                            }
                        },
                        { data: "serial", "visible": false ,width: "0%"},
                        { data: "serial", width: "30%" },
                        { data: "Datereg", width: "5%" },
                        { data: "Timereg", width: "10%" },
                        { data: "typef", width: "10%" },
                        { data: "Dsc1", width: "30%" },
                        { data: "Tel", width: "5%" },
                        { data: "Op1", width: "10%" }
        ], success: function (output, status) {
            if (output == 1) {
                alert("Record Deleted!");
            } else {
                alert("An error was encountered while attempting to update the record.");
            }
        }
        });

        dt.on('order.dt search.dt', function () {
            dt.column(1, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
                cell.innerHTML = i + 1;
            });
        }).draw();

        $('#failstable tbody').on('click', 'td.details-control', function () {
            var tr = $(this).closest('tr');
            var row = dt.row(tr);

            if (row.child.isShown()) {
                // This row is already open - close it
                row.child.hide();
                tr.removeClass('shown');
            }
            else {
                // Open this row
                row.child(format(row.data())).show();
                tr.addClass('shown');
            }
        });

i have the following problem :

I ve succesfully connected with an Oracle DB, and i ve constructed the model using the DB first approach provided by VS 2015 Community edition.

The problem starts when i try to add a controller / view with a declared model class, and data context class.

This is my db context class:

namespace ORACLETEST3.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;

public partial class HREntities : DbContext
{
    public HREntities()
        : base("name=HREntities")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //modelBuilder.Entity<>
        throw new UnintentionalCodeFirstException();
    }



    public virtual DbSet<BSNS_AREA> BSNS_AREA { get; set; }
    public virtual DbSet<MAIN> MAINs { get; set; }
    public virtual DbSet<OFFICE> OFFICEs { get; set; }
    public virtual DbSet<USER_TYPE> USER_TYPE { get; set; }
    public virtual DbSet<USR> USRs { get; set; }
}
}

When i try to add a view, i can -see- the data context class, but once i select one, i get an invocation error. Providing pics for reference :

enter image description here

If i dont select a data context class, i can add the view normally. If i do select a data context class, i get the following error:

enter image description here

This is what happens when i create an empty view, and try to bind the model:

@model ORACLETEST3.Models.USER_TYPE

@{
    ViewBag.Title = "View";
}

<h2>View</h2>

<div>
    <h4>USER_TYPE</h4>
    <hr />
    <dl class="dl-horizontal">
        <dt>
           @Html.DisplayNameFor(model => model.DESCR)
        </dt>

    <dd>
        @Html.DisplayFor(model => model.DESCR)
    </dd>

   </dl>
</div>
<p>
    @Html.ActionLink("Edit", "Edit", new { id = Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>

Is this some version mismatch thing?

I have two rails application which uses the same model, instead of having two different model directory and maintaining it separately, Is there any way to rip out the model directory and deploy it in a seperate server and make the two apps consume it? Or, is there any better solution for the problem?

I am storing service names outside of services table. So services table contains everything I need in a tableView except that I'd like to show service names stored in service_types in the view.
As far as I understood, there is no way to make QSqlTableModel work with even a simplest join.

I know I'm supposed to inherit QAbstractTableModel, but I have no idea how to implement anything there. A wizard in Qt Creator made a .h/.cpp pair for me, but I can't find any examples on the internet to get an idea what am I supposed to be implementing.

So, I'm asking if there is any clever way to get all service types strings (there are just 200) into a QMap beforehand, and just make tableView display them instead of IDs.

using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;

namespace ORACLETEST3.Models
{
    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
    public class ApplicationUser : IdentityUser
    {
        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("DefaultConnection", throwIfV1Schema: false)
        {
        }

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

and i get the following error, which seems inexplicable to me :

enter image description here

I m really new with mvc/ef, i understand this is some dependency problem with oracle, but i ve installed the following :

ODAC Release 4 Entity Framework 6.2

References : Oracle.ManagedDataAccess.dll Oracle.ManagedDataAccess.Entity.Framework

Is there a way i can cross-reference the versions to see if its the right one? Is this possibly due to a different problem? Thank you in advance.

This is my HTML code where i display match time, home team, away time and goals for half time and second half time:

<table>
  <tr>
   <td class="matchTime"></td>
   <td>
      <span class="homeTeamName">@homeMLName</span> - 
     <span class="AwayTeamName">@awayMLName</span>
   </td>
   <td>
      <span class="matchFHresults">-</span><br />
      <span class="matchFTresults">- </span>
   </td>
  <tr>

And this is my javascript function that allows me to update the goal for a specified time:

var UpdateGoal = function (matchID, result, IsFirst, isHome) {
var dataRow = $('tr.matchDisplayed[data-match-id="' + matchID + '"]');
$(dataRow).addClass("GoalHappened");
if (IsFirst) 
{
  $(dataRow).find(".matchFHresults").addClass("pulse").text(result);
   }
 else 
{
$(dataRow).find(".matchFTresults").addClass("pulse").text(result);
}
setTimeout(function () { $(dataRow).removeClass("GoalHappened"); }, 9000);
};

It updates the time every minute but not the goal when it happens.

we have an ASP.NET MVC site that we want to put through CloudFront (customer uses EC2 to host the application) - most of the site is static view content, however there is a "logged in state" that is processed through an XHR POST request to a loginPartial controller which ultimately sets the auth token. The site will display appropriately then to indicate the login has been successful

The objective is to essentially cache all pages /unless/ there's the _ASPNet_Authentication cookie present, in which case we'd return from origin every time.

I'm having a hard time getting this to work with Cloudfront in the way. I just get a 500 error with no more information:

X-Cache:Error from cloudfront

The static site bit works seemingly fine, I'm seeing a huge reduction on the server end-to-end time to around 20-30ms compared to about 900ms without CloudFront

However figuring out what should and shouldn't be present in headers to resolve this login is a bit of a minefield.

What cache headers, at a high level, do I need to be setting from the Application and also the CloudFront? Any CORS issues with proxying the site via a CNAME that I need to be aware of? Is this even a viable solution?

I looking for help with C# (cshtml) if statement, to display paragraph on only homepage site, like in php.

<?php
    if ($_SERVER['REQUEST_URI']=='/')
    {
        echo('<p>something</p>');
    }
?>   

Thanks in advance

I have this partial view:

@model GeomindEnterprise.Models.LoginViewModel

<div class="row">
    <div class="col-md-6 col-sm-6 col-xs-6">
        <!-- /SOCIAL LOGIN -->
        @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "sky-form", role = "form" }))
        {

            <fieldset class="nomargin">
                <div class="row">
                    <div class="col-md-10 col-md-offset-1">
                        @Html.AntiForgeryToken()

                        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                        <label class="input margin-bottom-10">
                            <i class="ico-append fa fa-envelope"></i>
                            @Html.TextBoxFor(m => m.UserName, new { @placeholder = "Email" })
                            @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })
                        </label>

                        <label class="input margin-bottom-10">
                            <i class="ico-append fa fa-lock"></i>
                            @Html.PasswordFor(m => m.Password, new { placeholder = "Password" })
                            @Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
                        </label>

                        <label class="form-group">
                            @Html.CheckBoxFor(m => m.RememberMe, new { @class = "col-md-1" })
                            @Html.LabelFor(m => m.RememberMe)
                        </label>

                        <footer>
                            <button type="submit" onclick="myFunction()" class="btn btn-default noradius pull-right"><i class="fa fa-check"></i> OK, LOG IN</button>
                        </footer>
                    </div>
                </div>

            </fieldset>

        }
    </div>
</div>

When I click button submit, this javascript method is called:

 function myFunction() {      
        debugger;
        jQuery.ajax({
            type: "POST",
            url: '@Url.Action("Login", "Account")',
            contentType: "application/json; charset=utf-8",
            data: jQuery('form').serialize(),
            datatype: "json",
            success: function (data) {
                debugger;
                jQuery('#myModalContent').html(data);
            },
            error: function () {
                alert("Dynamic content load failed.");
            }
        });
    }

The javascript method above calls this action:

//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
    //some logic
}

When the acction Login is called I get this error:

    The required anti-forgery form field "__RequestVerificationToken" is not present.

Any idea why I get this error?And how to fix it?

I am following the tutorial in which the instructor create a class for converting razor syntax to string which is right bellow .

 public static string RazorToString(Controller controller , string viewName , object model = null)
        {
            controller.ViewData.Model = model;
            using(var sw = new StringWriter())
            {
                ViewEngineResult viewResult;
                viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
                var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
                viewResult.View.Render(viewContext, sw);
                viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View);
                return sw.GetStringBuilder().ToString();
            }
        }

In the controller action he return the jSON like this.

return Json(new { success = true, html = RazorViewToString.RazorToString(this,"GetAll" ,), message = "submitted succesfully" }, JsonRequestBehavior.AllowGet);

The GetALL is the action method which he passed , which is returning the list of records. which is right below.

 public ActionResult GetAll()
        {
            using (DBModel db = new DBModel())
            {
                var list = db.Employees.ToList();
                return View(list);
            }
        }

This above method is the difference I mean in that tutorial the instructor has separately created a method which is getting the list and in this action method he called that method.but in my implementation i returing the list directly as you can seen above.so in the third parameter of

RazorViewToString.RazorToString(this,"GetAll" ,)

He passed that method which i not created , what i supposed to pass here ? and also if someone can describe the functionality above i will be thankful to him. #Peace

i need to use razor in my dll, so i added nuget packet MVC , create folder view with Web.Configue inside ,cleare and rebuild solutions and nothing. Any suggestions what I'm missing ? Class Library project

enter image description here

References in project

enter image description here

Web.config

    <?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="MyDllRootNameSpace" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.web>
    <compilation targetFramework="4.5">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>

  <system.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>

</configuration>

I'm in a situation where I would like to take a value from a page using JQuery, update the model with that value, call a method to update a different value in a model. Then call the controller to return a view with the new model.

I'm new to this so I imagine this is the wrong approach.

This is the View I have so far:

@using Cubic.OSS.SNMPMessageDuggerWebApplication.Models
@model SnmpModel
@{
   ViewBag.Title = "SNMP Message Debugger";
}

@section scripts
{

<script src="~/Scripts/jquery-1.7.1.js"></script>

<script type="text/javascript">

    $(document).ready(function() {


        $("#input-button").click(function () {
            // This is where I want the process to start.
        });


    });

</script>

}


<h2>@ViewBag.Title.</h2>
<div class="container-bar">
    <div id="input-bar">
        <p class="input-label">Enter SNMP Message: </p>
        <textarea rows="10" cols="300" id="input-area"></textarea>
        <br />
        <button id="input-button">Convert</button>
    </div>
    <div id="output-bar">
        <p class="output-label">Result: </p>
        <textarea rows="10" cols="300" id="output-area"></textarea>
    </div>
</div>

My model looks like this:

public class SnmpModel
{

    public string SnmpMessageInput { get; set; }
    public string SnmpMessageOutout { get; set; }


   // I Imagine a method would be added here to transform the input

}

And this is the controller so far:

public class SNMPController : Controller
{
    // GET: SNMP
    public ActionResult Index()
    {
        return View();
    }


}

What I don't know how to do is: update the model with the returned JQuery, then refresh the page with the new model using the controller.

The input would be taken from the input text area, then transformed.

Thanks.

I have a project that uses Autofac for constructor level injection. For every service instance, repositories are injected to constructor. Now to start using SpecFlow for the project I am not able to instantiate the service for method calls. I have already added Specflow.Autofac plugin but now I am getting following error. I have checked all referenced assemblies versions and those are correct.

enter image description here

Wanna test my project at another PC. To do this, I've moved my *.mdf file to root to my project's folder. What should I change on purpose to do this? P.S. SqlConnection class constructured as followed: SqlConnection (@"Data Source =(LocalDb); Initial Catalog = DBTest; Integrated Security = True")

Please help IE won't show Head-nav in chrome or firefox work good. Here is my code:

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>

 <div id="head-nav" class="navbar navbar-default">
      <div class="container-fluid">
           <div class="navbar-collapse">
                   <ul class="nav navbar-nav navbar-right user-nav">

How to implement a concept in Web Application where in i have the flow from one of my version say classic to a newer version we have hosted. For example in gmail(Regular to Html version) or SharePoint(between different versions) And also what key points to take care while doing the same.