I have an ASP.Net Core MVC with razor views that uses VueJs2 when it needs to be more complex.

I want to have a js file per view.

My folder structure is like that:

├ Controllers\HomeController.cs (with actions Index & Details)
├ Scripts\Home\index.ts
├ Scripts\Home\details.ts
├ Views\Home\Index.cshtml
├ Views\Home\Details.csthml
├ wwwroot\lib\vue
├ wwwroot\js\Home\index.js (generated with typescript)
├ wwwroot\js\Home\details.js (generated with typescript)
├ tsconfig.json

Here is my tsconfig.json

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "wwwroot/js",
    "rootDir": "Scripts",
    "allowSyntheticDefaultImports": true,
    "lib": [
      "dom",
      "es5",
      "es2015.promise"
    ]
  },
  "include": [
    "wwwroot/lib/vue/typings",
    "Scripts"
  ],
  "compileOnSave": true
}

My index.ts file

import Vue from 'vue'

var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Vue!'
    }
})

And the generated file:

"use strict";
var vue_1 = require("vue");
var app = new vue_1.default({
    el: '#app',
    data: {
        message: 'Hello Vue!'
    }
});
//# sourceMappingURL=index.js.map

In my Index.cshtml I load the js file but I have this require instruction that is not working in my browsers.

How to have this js files working within a browser?

I am trying to generate the URL with forward slash like the following

@Html.ActionLink("Details", "Details", new { id = item.StudentID, name = item.FirstName }) 

Desired Result:

http://www.example.com/Students/Details/3/ttcg
http://www.example.com/Students/Details/4/john
http://www.example.com/Students/Details/5/ronaldo

Current Result:

http://www.example.com/Students/Details/3?name=ttcg

Controller Action using RouteAttribute

[Route("Students/Details/{id}/{name?}")]
    public ActionResult Details(int? id, string name)
    {
        if (id.HasValue == false)
        {
            return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        }
        Student student = _studentService.GetDetail(id.Value);
        if (student == null)
        {
            return HttpNotFound();
        }
        student.FirstName += name;
        return View(student);
    }

Currently, I cheated by using this code to get the desired result.

<a href="Students/Details/@item.StudentID/@item.FirstName" >Details</a>

Is there a better way to generate the desired url like I want?

According to this post URL With RouteConfig.cs, do I have to add a new route in RouteConfig file? Does it mean that RouteAttribute does not support this kind of URL generation?

I am working on an ASP .net webpage which receives a form which is posted to it. The posted form has three as well.

filename = uploadFile(HttpContext.Current.Request.Files["file1"], path);

This is the code through which i upload a file to my server. And this is the code of the function.

public string uploadFile(HttpPostedFile file, string dest)
    {
        string filename = file.FileName;
        string path = Server.MapPath(dest);
        String extension = Path.GetExtension(file.FileName);
        filename = filename.Replace(extension, "");
        filename = filename.Replace(".", "");
        filename = System.DateTime.Now.ToString("ddMMyyyyhhmmss") + filename + extension;
        string savepath = path + "/" + filename;
        file.SaveAs(savepath);
        return filename;
    }

The problem is I am not able to check if file1 from the posted form actually has file. Is it possible?

I have a DataGrid with 12 columns and I am trying to put the first 6 columns in one row and the rest of the columns in another row straight under that so that it looks like this:

enter image description here

I was using two separate DataGrids but if there is more than one row it looks like this:

enter image description here

If I just use one DataGrid is there a way to add a break or new line to move some of the columns?

Code:

<asp:DataGrid CssClass="tblResults" runat="server" ID="dgNightline" AutoGenerateColumns="false" >
                                <HeaderStyle CssClass="tblResultsHeader" />
                                <AlternatingItemStyle BackColor="#EEEEEE" />
                                <Columns>
                                    <asp:BoundColumn DataField="FirstDocketNo" HeaderText="Cons No"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="JobNo" HeaderText="Job No"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="CustRef" HeaderText="Cust Ref"/>
                                    <asp:BoundColumn DataField="DeliverDate" HeaderText="Date"/>
                                    <asp:BoundColumn DataField="CollectionAddressName" HeaderText="Collect From"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="DdeliverToShortAddress" HeaderText="Deliver To"></asp:BoundColumn>
                                </Columns>
                            </asp:DataGrid>
                            <asp:DataGrid CssClass="tblResults" runat="server" ID="dgNightline2" AutoGenerateColumns="false">
                                <HeaderStyle CssClass="tblResultsHeader" />
                                <AlternatingItemStyle BackColor="#EEEEEE" />
                                <Columns>
                                    <asp:BoundColumn DataField="Description" HeaderText="Description"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="PieceBreakDown" HeaderText="Qty"></asp:BoundColumn>
                                    <asp:BoundColumn DataField="GrossWeight" HeaderText="Gross Wgt"/>
                                    <asp:BoundColumn DataField="ChgWeight" HeaderText="Chg Wgt"/>
                                    <asp:BoundColumn DataField="DelAmt" HeaderText="Amt"/>
                                </Columns>
                            </asp:DataGrid>

I am having textbox Input field and in that i have to check Multiple words. I am able to check single Word but not able to check multiple words. A list of word is stored in xml and from that i have to check. Need Help. Here MyName is Input Field Id and lblMyName is Label Id.

           if ($("#MyName").val() != '') {
                $.ajax({
                    type: "GET",
                    url: "Xml/Badwords.xml",
                    dataType: "xml",
                    success: function (xml) {

                        $(xml).find('Badwords').each(function () {

                             var flag = true;

                            $(this).children().each(function () {

                                var tagName = this.tagName;
                                var val = $(this).text();

         if (val.toLowerCase() == $("#MyName").val().toLowerCase())                       {
                                    $("#lblMyName").css("display", "block");

                                    $("#lblMyName").text("Please refrain from using profanity.");
                                    $(".postermyname").text('My Name);
                                     flag = false;
                                    return false;                                                                       

                                }

I want to store and update POST json data into a file using ASP.NET MVC.im send data

$http({
    url: "AddMenus",
    dataType: 'json',
    method: 'POST',
    data: MenusInfo,
    headers: {
           "Content-Type": "application/json"
    }
});

Add Menus is action method and MenusInfo is json object. Please help me out.. thanks in advance

I wish to copy data from my desktop application to another web solution I'm using. At the moment, I need to take each field and copy-paste it. Is there a way to map the desktop software and clipboard the data to an array/string that I can later use?

There aren't any API's around of course.

Thanks ahead!

Okay so I am trying to create a sort of registration wizard, so there are different sections within the asp such as the one below:

  <div class="panel panel-default">
        <div class="panel-heading">
          <h4 class="panel-title">
            <a href="#addwizard" data-parent="#accordion-demo" data-toggle="collapse">
              Term Time Address
            </a>
          </h4>
        </div>
        <div id="termaddy" class="panel-collapse collapse in"  runat="server">
          <div class="panel-body">
            <form id="form-termaddy" >
          <div class="main_input_box">
                 <div class="col-lg-6">

                    <div class="form-group">
                     <asp:TextBox ID="txttermhousenum" runat="server" placeholder="House Number" class="form-control" textmode="SingleLine"></asp:TextBox>
                         <asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator28" controltovalidate="housenum" errormessage="Required Field" display="Dynamic"/>
                 </div>

                   <div class="form-group">
                    <div class="main_input_box">
                     <asp:TextBox ID="txtxtermstreet" runat="server" placeholder="Street" class="form-control"  textmode="SingleLine"></asp:TextBox>
                         <asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator29" controltovalidate="street" errormessage="Required Field" display="Dynamic"/>
                 </div>
                       </div>

                   <div class="form-group">
                    <div class="main_input_box">

                     <asp:TextBox ID="txtxtermpost" runat="server" placeholder="Postcode" class="form-control" textmode="SingleLine"></asp:TextBox>
                         <asp:RequiredFieldValidator runat="server" id="RequiredFieldValidator31" controltovalidate="postcode" errormessage="Required Field" display="Dynamic"/>
                 </div>
                       </div>


                   </div>
               </div>
            </form>
          </div> <!--/.panel-body -->
        </div> <!-- /#addwizard -->
      </div> <!-- /.panel.panel-default -->

So whenever the user fills out the form and hits save. The c# gets the details of the text boxes and updates the db:

//term time address info
        string txttermhouse = ((TextBox)termaddy.FindControl("txttermhousenum")).Text;
        string txttermstr = ((TextBox)termaddy.FindControl("txtxtermstreet")).Text;
        string txttermpostcode = ((TextBox)termaddy.FindControl("txtxtermpost")).Text;

        termaddress(txttermhouse, txttermstr, txttermpostcode);

The issue is that when the code passes through this portion it sees each of the text boxes as blank and saves them in the db as and empty string. I have also tried directly referencing the textbox into the method, ie :

 termaddress(txttermhousenum.Text, txtxtermstreet.Text, txtxtermpost.Text);

But neither way seems to work. Any help on how to get the text box values would be greatly appreciated, very confused by this issue.

I have this line in my Razor :

@Html.Raw(File.ReadAllText(Server.MapPath("~/Views/Home/index.html")))

And in HTML file, I have this :

 <li><a href="#">Personal Records</a></li>

And in my js file I have this :

   if ($(link).text() === 'Personal Records') {
        $("#govde").load("PersonalRecords.html");
    }

But when I click on that link, nothing happens. When I open Index.html directly from file browser, it works. How can I fix this?

EDIT :

In console, it has this :

http://localhost:12345/PersonalRecords.html  404 (Not Found)

I guess I have placed the html files to a wrong folder. Can you tell me where to place? Thanks.

I have this line in my Razor :

@Html.Raw(File.ReadAllText(Server.MapPath("~/Views/Home/index.html")))

And in HTML file, I have this :

 <li><a href="#">Personal Records</a></li>

And in my js file I have this :

   if ($(link).text() === 'Personal Records') {
        $("#govde").load("PersonalRecords.html");
    }

But when I click on that link, nothing happens. When I open Index.html directly from file browser, it works. How can I fix this? Thanks.

One of my websites needs to call the API of another one of my websites.

My plan to display a "wait" popup while the page makes an AJAX call to direct the server-side code to make the API call.

But there is the potential that it could take a little while. I'm looking for advice on how to prevent the AJAX call from timing out.

When I Google this issue, most of the articles I've read suggest sending just a few items at a time. But in my case, it's all done in one rather substantial call.

What other options are there to prevent the page from timing out?

I've got this code which works to populate a second dropdownlist based on what's in the first one (in the page's Page_Init event):

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    . . .
    'Populate the Units dropdown
    Dim unitsDT As DataTable
    sql = "Select distinct unit from masterunits where abs(active) = 1"
    retDS = sqlDAL.runSQLDataSet(sql)
    unitsDT = retDS.Tables(0)
    DropDownListUnits.DataSource = unitsDT
    DropDownListUnits.DataTextField = "unit"
    DropDownListUnits.DataValueField = "unit"
    DropDownListUnits.DataBind()

    'Populate the Members dropdown based on Unit selected
    'Dim selectedUnit As String = DropDownListUnits.Text
    Dim selectedUnit As String = DropDownListUnits.SelectedItem.Text
    Dim membersDT As DataTable
    sql = "select distinct shortname, M.memberno from members M left join memberunitproducts mup on M.MemberNo = mup.MemberNo where unit = '" + selectedUnit  + "' order by shortname"
    retDS = sqlDAL.runSQLDataSet(sql)
    membersDT = retDS.Tables(0)
    DropDownListMembers.DataSource = membersDT
    DropDownListMembers.DataTextField = "shortname"
    DropDownListMembers.DataValueField = "memberno"
    DropDownListMembers.DataBind()
    . . .
End Sub

...I need to also update the second dropdown any time the first one changes, so have this code:

Protected Sub DropDownListUnits_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownListUnits.SelectedIndexChanged

DropDownListMembers.Items.Clear
    DropDownListCustomers.Items.Clear

    Dim selectedUnit As String = DropDownListUnits.SelectedItem.Text

    Dim sqlDAL As New SQLServer(ConfigurationSettings.AppSettings("ConnectionString"))
    Dim membersDT As DataTable
    Dim retDS As DataSet
    Dim sql As String = "select distinct shortname, M.memberno from members M left join memberunitproducts mup on M.MemberNo = mup.MemberNo where unit = '" + selectedUnit  + "' order by shortname"
    retDS = sqlDAL.runSQLDataSet(sql)
    membersDT = retDS.Tables(0)

    DropDownListMembers.DataSource = membersDT
    DropDownListMembers.DataTextField = "shortname"
    DropDownListMembers.DataValueField = "memberno"
    DropDownListMembers.DataBind()
End Sub

...but it doesn't work - selecting a different unit from DropDownListUnits does not change what is in DropDownListMembers.

Apparently this:

Dim selectedUnit As String = DropDownListUnits.SelectedItem.Text

...is not retrieving the new value selected from DropDownListUnits to selectedUnit.

I even added this, for debugging purposes:

Label2.Text = selectedUnit

...but Label2 never changes.

What am I doing wrong here?

UPDATE

Based on this, I also tried this:

Dim selectedUnit As String = DropDownListUnits.SelectedItem.ToString()

...but it makes no difference.

UPDATE 2

The event is apparently not even firing. This code:

Protected Sub DropDownListUnits_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownListUnits.SelectedIndexChanged
        Label2.Text = "it fired"
        . . .

...shows no change to Label2's text...

UPDATE 3

When I tried this as the first line in the Page_Init event:

If Not IsPostBack Then Exit Sub

...it doesn't even run once.

I already had a similar thing in there:

Dim PageAlreadyInitted As Boolean = False

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If PageAlreadyInitted = True Then Exit Sub
    PageAlreadyInitted = True
    . . .

I have a simple FileUpload box that is alble to accept files and save them to a location on a server on one web page, but the page I'm working on now has a form view inside of a radPageView, inside of a RadMultiPageView. When I attempt to see if there is a file in the FileUpload control, I am met with null values every time, eventhough I'm loading in a file. Here are some snippets of my code, trimmed down a little. Part of the problem is that in all of the tutorials I've found online, users are entering some of this information in the vb for the button click event, where I'm entering it in the xyz Handles .Updating section.

The prolem I run into is that when I get to the FileUpload1.HasFile it shows that there is no file, even if I have uploaded one. In fact, it shows Null, as if I haven't properly connected to the FileUpload control. I messed around with different ways to connect to the FileUpload control, but none of them really worked.

    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" CssClass="multiPage"
        BorderColor="Black" BorderStyle="Solid">
        <telerik:RadPageView ID="pvMemoDoc" runat="server">
            <asp:FormView ID="fvMemoDoc" runat="server" DefaultMode="Edit" DataSourceID="dsMemos"
                DataKeyNames="coreDocID">
                <EditItemTemplate>
                    <table class="tblNoSpace">
                        [...Other Code...]
                        <%--Begin file upload section--%>
                        <tr>

                            <td class="fieldLabel">File to upload:<br />
                            </td>
                            <td>
                                <asp:FileUpload ID="FileUpload1" runat="server" Width="600" ToolTip="Browse for file"   />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="text-align: right">
                                <asp:Label ID="lblFU1" runat="server" Enabled="false" Visible="false"
                                    Text="(only select new file if you wish to replace existing file)"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <br />
                                <br />
                                <asp:Button ID="btnUpdateMemo" CommandName="Update" runat="server" Text="Update Memo"
                                    CausesValidation="true" ValidationGroup="MemoInformation"
                                    ToolTip="Save updates" />&nbsp;
                            </td>
                        </tr>
                    </table>
                </EditItemTemplate>
            </asp:FormView>
        </telerik:RadPageView>

        [...Other Code...]

    </telerik:RadMultiPage>

VB Code:

Private Sub DsMemo_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsMemos.Updating
    Dim FileUpload1 As FileUpload = CType(fvMemoDoc.FindControl("FileUpload1"), FileUpload)
    'Dim FileUpload1 As FileUpload = CType(fvMemoDoc.Controls(0).Controls(0).FindControl("FileUpload1"), FileUpload)
    'Dim FileUpload1 As FileUpload = CType(fvMemoDoc.Controls(0).FindControl("FileUpload1"), FileUpload)
    'Dim FileUpload1 As FileUpload = TryCast(updateButton.Parent.Parent.FindControl("FileUpload1"), FileUpload)

    If FileUpload1.HasFile Then
        [...Other Code Here..]
        [...Never gets past FileUpload1.HasFile...]
    End If
End Sub

I have a search feature built into a page that hits an API to get a list of items if a user chooses to search instead of manually enter (in an attempt to get some clean data). I have the first column of said table set to call a JavaScript function onclick. That function looks similar to this:

function loadDataFromTable(fname, lname, mname, stn, grade, school) {
        $('#StudentFirstName').val(fname);
        $('#StudentLastName').val(lname);
        if (mname !== "undefined") {
            $('#StudentMiddleName').val(mname);
        }
        else {
            $('#StudentMiddleName').val('');
        }
        $('#StudentNumber').val(stn);
        $('#Grade').val(grade);
        $('#School').val(school);
        return false;
    }

The associated HTML elements are all ASP.NET Core Razor View input elements. They look like this:

<div class="form-group">
        <label class="col-md-3 control-label">Last Name</label>
        <div class="col-md-9">
            <input type="text" asp-for="StudentLastName" class="form-control" />
            <span asp-validation-for="StudentLastName" class="text-danger"></span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-3 control-label">STN</label>
        <div class="col-md-9">
            <input type="text" asp-for="StudentNumber" class="form-control" />
            <span asp-validation-for="StudentNumber" class="text-danger"></span>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-3 control-label">Grade</label>
        <div class="col-md-9">
            <input type="text" asp-for="Grade" class="form-control" />
            <span asp-validation-for="Grade" class="text-danger"></span>
        </div>
    </div>
    <div class="form-group">
        <label asp-for="School" class="col-md-3 control-label"></label>
        <div class="col-md-9">
            <select asp-for="School" asp-items="ViewBag.SchoolList" class="form-control"></select>
            <span asp-validation-for="School" class="text-danger"></span>
        </div>
    </div>

Now, if a user clicks on one of the links from the table, all of the values are properly passed into the function, and all of the values for First Name, Last Name, Middle Name, and STN properly update on the view. Grade and School do not update on the View, but their value attribute does update. When I submit the form after the data fills, the correct values are passed to my controller.

What I can't figure out is why the Grade and School values are not populating on the view. The only thing that stands out as different for these two are within the model they are nullable integers, whereas other fields are strings.

I have tried a mixture of .attr('value', grade), .text(grade), and .val(grade), and none of them are working. I can verify that the proper elements are being selected because if I output $('#Grade') I get the input object.

I have a data base with three tables. Users, messages and commits. The site boots up and I can login and register just fine When I go to post a message I am getting the following error.

MySqlException: Cannot add or update a child row: a foreign key constraint fails (thewall.messages, CONSTRAINT fk_messages_users1 FOREIGN KEY (user_id) REFERENCES users (UserId) ON DELETE NO ACTION ON UPDATE NO ACTION)

Looking up the error I know it has something to do with the many to 1 relation ship ie foreign key. But after looking at this and dumping the database 100 times. I need another pair of fresh eye to see if they can spot it.

MessageFactory.cs

public void Add(Message Item)
{
    using(IDbConnection dbConnection = Connection)
    {
        string Query = "INSERT INTO messages (MessageContent, PosterId, CreatedAt, UpdatedAt) VALUES (@MessageContent, @PosterId, NOW(), NOW())";
        dbConnection.Open();
        dbConnection.Execute(Query, Item);
    }

}

Table in question is setup like so

MessageId
MessageContent
PosterId
Createdat
Updatedat
user_id  <this is the foreign key> linking it to users.  


MessagesController.cs

 public IActionResult CreateMessage(Message model)
        {
            if(!CheckLogin())
            {
                return RedirectToAction("RegisterPage", "Users");
            }
            if(ModelState.IsValid)
            {
                model.PosterId = (int)HttpContext.Session.GetInt32("CurrUserId");
                _messageFactory.Add(model);
                return RedirectToAction("Index");
            }
            List<Message> AllMessages = _messageFactory.GetAllMessages();
            ViewBag.CurrentUser = _userFactory.GetUserById((int)HttpContext.Session.GetInt32("CurrUserId"));
            ViewBag.Messages = AllMessages;
            return View("Index", model);
        }

Any help would be greatly appriacted.

I am starting the development on a system which will be built using ASP.NET 4.6, MVC with Razor, JQuery, JQueryUI, etc. I wanted to use the newest stable version of JQuery (to my knowledge, 3.2.1), however when using NuGet to install some packages, some older versions are added to the Visual Studio project.

What I need to figure out is - for the built in .NET tools like AJAX.BeginForm, the unobtrusive jquery lib, etc, do I need to target a specific JQuery version? Is there some place I can see version requirements for these?

If anyone can answer or point me in the right direction, I'd appreciate it - thanks!

I have a mobile app that posts to my ASP.NET MVC 4 HttpPost method and every time it receives data, it's not receiving the correct data.

[HttpPost]
public void NewItems(Dictionary<string, List<Dictionary<string, string>>> newItemsDictionary) 
{
}

I have my RouteConfig setup as follows:

routes.MapRoute(
            name: "Default",
            url: "{action}",
            defaults: new { controller = "API", action = "Index" }
        );

The mobile app is posting to the URL https://api.test.com/NewItem and the parameters are a JSON encoded dictionary with one key, newItems and the value is an array of dictionaries ([["user": "testUser1", "itemNumber": "123-45678"], ["user": "testUser2", "itemNumber": "456-7890"]])

I have a try/catch block setup inside the POST method to catch any errors. When the method is posted to, it goes into the catch block and tells me that the "newItem" key doesn't exist within the newItemsDictionary parameter. The keys that do exist in the parameter are: action and controller. The action and controller keys do not contain any values.

Why is this happening and what should I change to receive the correct data?

enter image description herei have successfully been able to clone the div elements which i wanted to clone. the issue is that when the user insert data into the input and click the button to clone the input field, it clones the last input field with the data (Please see image for example). my goal is to clone the div element with the new id so when the user click on the button it does clone the previous input field without grabbing the data from the previous input field.

       <div id ="specdiv ">
         <fieldset class="fieldset">
              <legend class="legend">Question Specification</legend>
                 <div class="editor-label">
            @Html.LabelFor(model => model.OfferedAnswer)
        </div>
            <div class ="answerchoice1" id="">
         <div class="editor-field">
           @Html.TextAreaFor(model => model.OfferedAnswer.AnswerText)




        </div>
                </div>

             </fieldset>


    </div>



 <button id="quesId" class="mini-button" type =" button">+</button>


    $(document).ready(function () {
    $('button').click(function () {
        //$('.answerchoice1').before($('.answerchoice1').clone())
        if ($('.editor-field').length >= 10) {
           // alert('No more than 6!');
            $("<div title='Answers Limit has been reached'> You cannot add more anwer choice if you would like to add more please consider to create a new question. Thank you </div>").dialog(

            );
            return false;
        }
        var $target = $('.answerchoice1').find('div.editor-field:first');
        $target.clone().appendTo('.answerchoice1');
        $target.find('.answerchoice1').val("");
        $target.insertAfter(".div.editor-field:last")
        var tID = $(this).attr(".answerchoice1").split(/ _/);

        //console.log($('.example-1').html());
    })

})

When I'm trying to build string with String.Format() method in Razor views, I pass string built by user in satelite system.

Sometimes, the users forgot put all paramters in brackets and String.Format method throws exception.

For example:

The userString is "My name is {0} and my lastname is {1}"

And the code is:

@string.Format(userString, param1, param2, param3);

What's the better way to avoid this exception?

NOTE: I can't put try/catch block because our views are plagued of String.Format()

NOTE: The exception is:

'System.FormatException' occurred in mscorlib.dll but was not handled in user code when I use some

whe I used code like this:

@string.Format("{0}{1}", 1)

Recently i installed Visual Studio 2017 Enterprise. But when i open any file (like .cs,.cshtml), every time the cursor changes to a gray rectangle and editor acts as if its in Over-strike mode even though the indicator at the bottom of the window says "INS". So I hit the insert button several times and cycle through "OVR" and back to "INS" and the cursor goes back to "|" and I start to coding. Then the moment I highlight some text it happens all over again. This is very frustrating and also painful. Double clicking the indicator has the same temporary result as the Insert button.

I'm using structuremap with hangfire on asp.net core, no error on application but hangfire not process queue/schedule task even though data already on database. Here my snippet configuration

public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        // setup automapper
        var config = new AutoMapper.MapperConfiguration(cfg =>
        {
            cfg.AddProfile(new AutoMapperProfileConfiguration());
        });

        var mapper = config.CreateMapper();
        services.AddSingleton(mapper);


        // Bind settings parameter
        services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));

        // Add framework services.
        services.AddApplicationInsightsTelemetry(Configuration);
        services.Configure<RouteOptions>(options => options.LowercaseUrls = true);
        services.AddDbContext<DefaultContext>(options =>
            options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

        services.AddHangfire(options => 
            options.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection")));

        services.AddMvc();
        // ASP.NET use the StructureMap container to resolve its services.
        return ConfigureIoC(services);
    }

    public IServiceProvider ConfigureIoC(IServiceCollection services)
    {
        var container = new Container();

        GlobalConfiguration.Configuration.UseStructureMapActivator(container);

        container.Configure(config =>
        {
            // Register stuff in container, using the StructureMap APIs...
            config.Scan(_ =>
            {
                _.AssemblyContainingType(typeof(Startup));
                _.WithDefaultConventions();
                _.AddAllTypesOf<IApplicationService>();
                _.ConnectImplementationsToTypesClosing(typeof(IOptions<>));
            });
            config.For<ILog>().Use(c => LoggerFactory.LoggerFor(c.ParentType)).AlwaysUnique();
            XmlDocument log4netConfig = new XmlDocument();
            log4netConfig.Load(File.OpenRead("log4net.config"));

            var repo = LogManager.CreateRepository(
                Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));

            XmlConfigurator.Configure(repo, log4netConfig["log4net"]);
            //Populate the container using the service collection
            config.Populate(services);
        });

        return container.GetInstance<IServiceProvider>();
    }

Is there any better way using hangfire and structuremap on asp.net core? Am I missing something so hangfire not working properly?