I have made a RESTful API and when testing it on localhost it works fine, now I've added it to our IIS 8 and now I recieve the following error

XMLHttpRequest cannot load http://egluit.dk/api/call/. Response for preflight has invalid HTTP status code 500

When checking the network console I see this:

General
Request URL:http://egluit.dk/api/call/
Request Method:OPTIONS
Status Code:500 Internal Server Error
Remote Address:212.112.133.213:80

Response Headers
view source
Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:POST,GET,OPTIONS
Access-Control-Allow-Origin:*
Content-Length:1208
Content-Type:text/html
Date:Fri, 23 Dec 2016 17:19:03 GMT
Server:Microsoft-IIS/8.5

Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:da-DK,da;q=0.8,en-US;q=0.6,en;q=0.4
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:egluit.dk
Origin:http://localhost:82
Referer:http://localhost:82/
User-Agent:Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

I've already added CORS support in my C# code

public static void Register(HttpConfiguration config)
    {
        ..

        //  Allow Cross-origin request
        config.EnableCors();

        ...
    }

and after reading this post Configure IIS Express 8 to enable CORS I've added this to my web.config

<system.webServer>
   <httpProtocol>
    <customHeaders>
      <add name="Access-Control-Allow-Origin" value="*"/>
      <add name="Access-Control-Allow-Headers" value="Content-Type"/>
      <add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS"/>
    </customHeaders>
  </httpProtocol>
    <handlers>
      <clear name="ExtensionlessUrlHandler-Integrated-4.0" />
      <clear name="OPTIONSVerbHandler" />
      <clear name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>

but to no success. Any idea what I'm doing wrong. If possible I would like to keep the solution to web.config or C#.

The client I'm using is an AngularJS application where the call looks like this:

var req = {
    method: 'Post',
    url: 'http://egluit.dk/api/call/',
    data: data
}
$http(req)
   .then(function(response){
        console.log(JSON.parse(response))
   })
   .catch(function(error){
        console.error(error);
   })

protected void Page_Load(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;
        if (IsPostBack)
        {
            if (dllselection.SelectedValue == "3")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("OJT.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "cpgintranet@2016", "192.168.2.5", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();

            }
            else if (dllselection.SelectedValue == "4")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("TEFF.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "cpgintranet@2016", "192.168.2.5", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();


            }
        }
    }

 protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Buffer = true;
if (dllselection.SelectedValue == "3")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("OJT.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "abc@2016", "192.168.2.88", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();

            }
            else if (dllselection.SelectedValue == "4")
            {
                ReportDocument myDataReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
                myDataReport.Load(Server.MapPath("TEFF.rpt"));
                myDataReport.SetDatabaseLogon("intranet", "abc@2016", "192.168.2.88", "INTRANET");
                myDataReport.SetParameterValue("T-ID", TextBox1.Text);
                CrystalReportViewer1.ReportSource = myDataReport;
                CrystalReportViewer1.DataBind();


            }
}

i am getting error :

The maximum report processing jobs limit configured by your system administrator has been reached."

Having researched the topic online I found some solution,set registry value, specifically HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit to "-1" ,but this solution is not working,if I adding crystal report dispose and close function in my code,the crystal report I generated will be empty. Below are my aspx code:

<asp:DropDownList ID="dllselection"  onchange="javascript:return dropdown(this);" runat="server" Style="border: groove" CssClass="form-control" AutoPostBack="true">
                    <asp:ListItem Text="On Job Training" Value="3"></asp:ListItem>
                    <asp:ListItem Text="Training Effectiveness Form" Value="4"></asp:ListItem>
                </asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Generate" CssClass="btn btn-success" OnClick="Button1_Click" />
        <div id="dvReport">
            <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" ToolPanelView="None" EnableDatabaseLogonPrompt="False" PrintMode="Pdf" />
        </div>

I'm Using Web Api with Entity Framework, I have a controller named as Gift, when client GET's the API I'm getting all Gifts from DB by using entity framework and and returning it as JSON

Here is my controller function

    public List<Gift> Get()
    {
        return GiftService.GetIncludeAndActive();
    }

Here is Service Function

public List<Gift> GetIncludeAndActive()
{
    return dbSet.Include("GiftCategory").Where(x => x.Status == Model.Enums.GiftStatus.Active).OrderByDescending(x => x.Featured).ThenBy(x => x.Price).ToList();
}

Here is Gift Model

public class Gift
    {
        public Gift()
        {
            this.CartItems = new List<CartItem>();
        }
        public int ID { get; set; }
        public string GiftName { get; set; }
        public string Image { get; set; }
        public int Stock { get; set; }
        public int Price { get; set; }
        public string Description { get; set; }
        public string Status { get; set; }
        public string GiftCode { get; set; }
        public int GiftCategoryID { get; set; }
        public Nullable<DateTime> CreatedAt { get; set; }
        public Nullable<DateTime> UpdatedAt { get; set; }
        public bool Featured { get; set; }
        public GiftCategory GiftCategory { get; set; }
        public ICollection<CartItem> CartItems { get; set; }

    }

[

Here is the JSON Output

{
        "$id": "1",
        "ID": 14,
        "GiftName": "Sinbo SVC-3438 1600 Watt Elektrikli Süpürge",
        "Image": "http://placehold.it/400x288.jpg/A6A",
        "Stock": 70,
        "Price": 260,
        "Description": "Az yer kaplayan Kompakt dizayn, Max. 1600W, 5m kablo uzunluğu, 360 derece dönüş açılı ön tekerlek, Dar ve ulaşılması zor yerler için 2 si 1 arada aparat ",
        "Status": "Active",
        "GiftCode": "BDRS-498",
        "GiftCategoryID": 4,
        "CreatedAt": "2016-12-19T12:59:01.31",
        "UpdatedAt": "2016-12-19T12:59:10.54",
        "Featured": false,
        "GiftCategory": {
          "$id": "2",
          "ID": 4,
          "Name": "Kişisel Bakım",
          "CountryID": 1,
          "Country": null,
          "Gifts": [
            {
              "$ref": "1"
            },
            {
              "$id": "3",
              "ID": 11,
              "GiftName": "Kişisel Bakım 2 - LG 43LH590V 43\"108 Ekran Full HD",
              "Image": "http://placehold.it/400x288.jpg/AEA",
              "Stock": 50,
              "Price": 3600,
              "Description": "Triple XD Engine teknolojisiyle güçlendirilen, Active Noise Reduction ve Real Cinema 24p özellikleriyle zenginleştirilen 1080p çözünürlüğündeki LED aydınlatmalı 55 inçlik ekrana sahip model, size ideal sinema keyfi sunuyor. Aynı zamanda sahip olduğu Color Prime, Dynamic Clear White ve Dynamic Colour Enhancer özellikleri sayesinde kusursuz bir görüntüyle evlerinizde yerini alıyor.",
              "Status": "Active",
              "GiftCode": "BDRS-495",
              "GiftCategoryID": 4,
              "CreatedAt": "2016-12-19T12:59:01.31",
              "UpdatedAt": "2016-12-19T12:59:10.54",
              "Featured": false,
              "GiftCategory": {
                "$ref": "2"
              },
              "CartItems": []
            },
            {
              "$id": "4",
              "ID": 8,
              "GiftName": "Kişisel Bakım 1 - Apple iPhone 6S 16 GB",
              "Image": "http://placehold.it/400x288.jpg/CCC",
              "Stock": 100,
              "Price": 5000,
              "Description": "Teknolojinin sunduğu tüm imkanlardan yararlanılarak tasarlanan Apple iPhone 6S , hem işlevsel hem de görsel açıdan ayrıcalıklı bir akıllı telefona sahip olmanıza olanak tanıyor.",
              "Status": "Active",
              "GiftCode": "BDRS-492",
              "GiftCategoryID": 4,
              "CreatedAt": "2016-12-19T12:59:01.31",
              "UpdatedAt": "2016-12-19T12:59:10.54",
              "Featured": false,
              "GiftCategory": {
                "$ref": "2"
              },
              "CartItems": []
            }
          ]
        },
        "CartItems": []
      },
      {
        "$id": "5",
        "ID": 13,
        "GiftName": "Beyaz Eşyalar 2 - Philips Marathon Ultimate FC9919/07 A Sınıfı Toz Torbasız Elektrikli Süpürge",
        "Image": "http://placehold.it/400x288.jpg/A1A",
        "Stock": 70,
        "Price": 900,
        "Description": "Yeni Philips Marathon Ultimate torbasız elektrikli süpürge, üstün temizlik performansı sunar. PowerCyclone 7, havayla tozu olağanüstü bir performansla ayırır. TriActiveMax başlık ise tüm zeminlerde mükemmel performans gösterir.",
        "Status": "Active",
        "GiftCode": "BDRS-497",
        "GiftCategoryID": 2,
        "CreatedAt": "2016-12-19T12:59:01.31",
        "UpdatedAt": "2016-12-19T12:59:10.54",
        "Featured": false,
        "GiftCategory": {
          "$id": "6",
          "ID": 2,
          "Name": "Beyaz Eşyalar",
          "CountryID": 1,
          "Country": null,
          "Gifts": [
            {
              "$ref": "5"
            },
            {
              "$id": "7",
              "ID": 6,
              "GiftName": "Beyaz Eşyalar 1 - Samsung Galaxy S7 Edge",
              "Image": "http://placehold.it/400x288.jpg/EEE",
              "Stock": 100,
              "Price": 6000,
              "Description": "Teknolojik yeniliklerin nereye kadar ulaşacağını kestiremeyen kullanıcılar, Samsung’un geliştirdiği ve bünyesinde barındırdığı yenilikçi özelliklerle öne çıkan telefonlarla şaşırmaya devam ediyor. Galaxy serisi içerisindeki en agresif atılımları üzerinde bulunduran Samsung Galaxy S7 Edge modelleri;alüminyum çerçeveleri, güçlü donanımları, benzersiz kameraları, suya ve toza karşı dayanıklılıkları ve sanal gerçeklik aygıtlarına doğrudan bağlanabilmeleriyle benzersiz hale geliyorlar.",
              "Status": "Active",
              "GiftCode": "BDRS-490",
              "GiftCategoryID": 2,
              "CreatedAt": "2016-12-19T12:59:01.31",
              "UpdatedAt": "2016-12-19T12:59:10.54",
              "Featured": false,
              "GiftCategory": {
                "$ref": "6"
              },
              "CartItems": []
            }
          ]
        },
        "CartItems": []
      },
      {
        "$id": "8",
        "ID": 7,
        "GiftName": "Elektronik 1 - Samsung Galaxy J7",
        "Image": "http://placehold.it/400x288.jpg/DDD",
        "Stock": 1000,
        "Price": 2500,
        "Description": "eknolojik yenilikleri yakından takip eden herkesin kullandığı akıllı cep telefonları, gelişmiş donanım ve yazılım özelliklerinin yanı sıra üzerlerinde bulunan kameralarla daha da kullanışlı hale geliyor. Dünya çapında milyonlarca kullanıcıya ulaşan ve akıllı cep telefonu sektörüne yön veren başlıca markalardan biri olan Samsung, Galaxy serisi içerisine konumlandırdığı Samsung Galaxy J7 modeliyle kendinden söz ettiriyor. ",
        "Status": "Active",
        "GiftCode": "BDRS-491",
        "GiftCategoryID": 3,
        "CreatedAt": "2016-12-19T12:59:01.31",
        "UpdatedAt": "2016-12-19T12:59:10.54",
        "Featured": false,
        "GiftCategory": {
          "$id": "9",
          "ID": 3,
          "Name": "Elektronik ",
          "CountryID": 1,
          "Country": null,
          "Gifts": [
            {
              "$ref": "8"
            },
            {
              "$id": "10",
              "ID": 12,
              "GiftName": "Elektronik  2 - Samsung 40JU6070 40\" 102 Ekran Ultra HD",
              "Image": "http://placehold.it/400x288.jpg/A6A",
              "Stock": 62,
              "Price": 3200,
              "Description": "TV standında kullanılabilen model, A enerji verimlilik sınıfında yer alıyor. Samsung 40JU6070 fiyatı kullanıcı açısından tercih edilir olmasında önemli bir rol oynuyor.4K teknolojisiyle yeni tanışacak olanların rahatlıkla yönelebilecekleri model, zengin giriş - çıkış noktalarıyla da cazip seçenekler arasında yer alıyor. Slim yapısı, pratik kullanımı ve gerek donanım gerekse yazılım anlamında Samsung’un elektronik alandaki deneyiminin bir eseri olarak nitelenebilecek akıllı televizyon, salon ya da oturma odalarınızın en sevilen eşyalarından biri oluyor.",
              "Status": "Active",
              "GiftCode": "BDRS-496",
              "GiftCategoryID": 3,
              "CreatedAt": "2016-12-19T12:59:01.31",
              "UpdatedAt": "2016-12-19T12:59:10.54",
              "Featured": false,
              "GiftCategory": {
                "$ref": "9"
              },
              "CartItems": []
            }
          ]
        },
        "CartItems": []
      },
      {
        "$id": "11",
        "ID": 9,
        "GiftName": "Küçük Ev Aletleri 1 - General Mobile 4G Android One",
        "Image": "http://placehold.it/400x288.jpg/BBB",
        "Stock": 150,
        "Price": 2600,
        "Description": "General Mobile 4G , diğer akıllı telefon modellerinden farklı olarak Google iş birliği ile geliştirilen Türkiye'deki ilk Android One cihaz olma özelliğine sahip ve bu yüzden benzeri bulunmayan eşsiz bir ürün.",
        "Status": "Active",
        "GiftCode": "BDRS-493",
        "GiftCategoryID": 5,
        "CreatedAt": "2016-12-19T12:59:01.31",
        "UpdatedAt": "2016-12-19T12:59:10.54",
        "Featured": false,
        "GiftCategory": {
          "$id": "12",
          "ID": 5,
          "Name": "Küçük Ev Aletleri",
          "CountryID": 1,
          "Country": null,
          "Gifts": [
            {
              "$ref": "11"
            }
          ]
        },
        "CartItems": []
      },
      {
        "$id": "13",
        "ID": 10,
        "GiftName": "Elektrikli Ev Aletleri 2 - Samsung 40J5070 40\" 102 Ekran Full HD",
        "Image": "http://placehold.it/400x288.jpg/AAA",
        "Stock": 50,
        "Price": 3000,
        "Description": "\r\nMarkaların ortaya koydukları televizyon modelleri, farklı donanım ve yazılım özellikleriyle öne çıkıyor. Gelişmiş 3D yetenekleri ve 4K çözünürlükleriyle sunulan bazı ürünler, sahip oldukları aygıttan çok sayıda özellik bekleyenlerin gereksinimlerini kolayca karşılıyor.",
        "Status": "Active",
        "GiftCode": "BDRS-494",
        "GiftCategoryID": 1,
        "CreatedAt": "2016-12-19T12:59:01.31",
        "UpdatedAt": "2016-12-19T12:59:10.54",
        "Featured": false,
        "GiftCategory": {
          "$id": "14",
          "ID": 1,
          "Name": "Elektrikli Ev Aletleri",
          "CountryID": 1,
          "Country": null,
          "Gifts": [
            {
              "$ref": "13"
            },
            {
              "$id": "15",
              "ID": 5,
              "GiftName": "Elektrikli Ev Aletleri 1 - Iphone 7 Plus 128GB",
              "Image": "http://placehold.it/400x288.jpg/FFF",
              "Stock": 200,
              "Price": 7500,
              "Description": "Apple markası iPhone serisi altında sunduğu cihazların arasına geçtiğimiz yıllarda Plus serisini de eklemişti. iPhone 7 cihazının yanı sıra sunulan iPhone 7 Plus , yüksek özellikleri ve normal iPhone’a göre büyük ekranı ile büyük ekran beklentisi olanların ihtiyacını karşılamayı hedefliyor.",
              "Status": "Active",
              "GiftCode": "BDRS-489",
              "GiftCategoryID": 1,
              "CreatedAt": "2016-12-19T12:59:01.31",
              "UpdatedAt": "2016-12-19T12:59:10.54",
              "Featured": false,
              "GiftCategory": {
                "$ref": "14"
              },
              "CartItems": []
            }
          ]
        },
        "CartItems": []
      },
      {
        "$ref": "10"
      },
      {
        "$ref": "3"
      },
      {
        "$ref": "4"
      },
      {
        "$ref": "7"
      },
      {
        "$ref": "15"
      }
    ]

As you can see there is "$ref":"13", "$ref":"14" etc... I don't want to show that $refs at the bottom of the json, I don't want $refs. I want a regular JSON file

And here is my WebApiConfig.cs

     public static void Register(HttpConfiguration config)
        {

            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
.....

I can fix this problem by using a very mystic way; I'm adding a new blank line to web.config file and saving it, then I'm calling the API again and wholaa it is OK as I want.

But after 1-2 hours starting to send data with $ref until I add a new blank line to web.config file.

 @Html.ActionLink("Create New", "Create",null , new { id = "btnCreate" })

below code is part of html table

<td>
@Html.ActionLink("Edit", "Edit", new { id = item.UserId }, new { @class = "edit"}) |
@Html.ActionLink("Details", "Details", new { id = item.UserId }, new { @class = "details" }) |
@Html.ActionLink("Delete", "Delete", new { id = item.UserId }, new { @class = "delete" })
</td>

I'm a Beginner...help me with some simple jquery code

I have a table td's set up like this:

  @foreach (var item in ViewBag.WatchListCompetitor)
                    {
                        <tr role="row" class="odd">
                            <td class="" tabindex="0">@item.SentWord</td>
                            <td class="sorting_1">@item.Comment</td>
                            <td class="sorting_1">@item.Rating</td>
                            <td class="sorting_1">@item.SellerFeedback</td>
                            <td class="sorting_1 deleteAction"><i class="fa fa-close"></i></td>
                            <td class="idRow" style="display:none;" id="@item.WatchListID">@item.WatchListID</td>
                        </tr>
                    }

And I've defined an onclick event like this to try to get the idRow value when the "delete action" is triggered...

   $(document).ready(function () {
        $('.deleteAction').click(function () {

            console.log($(this).closest("td"));
        });
    });

The result that I get is:

Object { length: 1, prevObject: Object, context: <td.sorting_1.deleteAction>, 1 more… }

How can I fetch the td idRow value when event is triggered?

I am trying to export html to pdf but when pdf is exported it shows English characters only and Arabic is missing bellow is my code. Any one have solution?

string data = "<table><tr><td>Hello</td></tr><tr><td>لورانس العرب</td></tr></table>";
            ArrayList htmlarraylist = HTMLWorker.ParseToList(new StringReader(data), null);
            htmlarraylist = HTMLWorker.ParseToList(new StringReader(data), null);
            Document myDocument = new Document(PageSize.A4.Rotate());
            PdfWriter.GetInstance(myDocument, new FileStream(HttpContext.Current.Server.MapPath("~/MyPDF_FilePath"), FileMode.Create));
            myDocument.Open();
            foreach (var t in htmlarraylist)
            {
                myDocument.Add((IElement)t);
            }
            myDocument.Close();

I am trying to upload multiple files.. if he/she wants.. when they click on upload more files then want to display another upload .. and when when click on submit then want to insert data.. insert is not problem .. problem is when they click on upload more files then how to upload multiples

HTML

<div>
        <asp:FileUpload ID="FileUpload1" runat="server" />

  <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Upload more files</asp:LinkButton>
<br />

        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </div>

protected void Button1_Click(object sender, EventArgs e)
        {
            var message = "";

            var fileName = "";
            var fileSavePath = "";
            int numFiles = Request.Files.Count;
            int uploadedCount = 0;
            for (int i = 0; i < numFiles; i++)
            {
                var uploadedFile = Request.Files[i];
                if (uploadedFile.ContentLength > 0)
                {
                    fileName = Path.GetFileName(uploadedFile.FileName);
                    fileSavePath = Server.MapPath("~/App_Data/UploadedFiles/" +
                      fileName);
                    uploadedFile.SaveAs(fileSavePath);
                    uploadedCount++;
                }
            }
            message = "File upload complete. Total files uploaded: " +
              uploadedCount.ToString();
        }


        protected void LinkButton1_Click(object sender, EventArgs e)
        {

        }

i dont want only 1 upload i.e when click on browse then user may select different files.. and then upload .. but what if file is in different location then how they select. so i want when user click on upload more files then want to display fileupload

I want to load data from database table's Column (1 Column only) in a dropdown using MVC.

I have the following code for SWITCH statement (Razor - ASP.NET MVC). It is giving syntax error. Can you provide me the correct syntax code ?

@switch (DateTime.Now.Hour)
{
    case < 12: // ERROR HERE
        message="Morning.";
        break;
    case > 12: // ERROR HERE
        message="Evening.";
        break;
    default:
        message="Afternoon";
        break;
}

Thanks

I am creating the ASP.NET which is calling a third party Rest API. The third party API can be accessed only giving username and password. Also uses Http Basic Authentication

 public string Get(string LabName)
   {
    string userName = ConfigurationManager.AppSettings["username"];
    string password = ConfigurationManager.AppSettings["password"];
    string BaseURL = ConfigurationManager.AppSettings["BaseURL"];

    using (var client = new HttpClient())
    {

        Uri uri = new Uri(BaseURL);
        client.BaseAddress = uri;
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
        string clarity_URL = BaseURL+"api/v2/labs?name="+LabName;
        var response = client.GetAsync(clarity_URL).Result;

        string responseString = response.Content.ReadAsStringAsync().Result;
        return responseString;

Should I be using HttpClient or HttpWebRequest.I am not sure how to pass the username and password while calling the Rest API in the ASP.NET.Can anyone suggest me how to securely call the API

I'm having some issues with updating a partial view in my index view. Basically, based on a click, I would like to have updated information.

    //controller
    public ActionResult Index()
    {
        var filteredObservations = getFilteredObservationSessions().ToList();
        var observationManagementVm = new ObservationManagementVM(filteredObservations);

        return View(observationManagementVm);
    }

    public ActionResult indexPagedSummaries(int? page, List<ObservationSessionModel> data)
    {
        var alreadyFilteredObservations = data;
        int PageSize = 10;
        int PageNumber = (page ?? 1);

        return PartialView(alreadyFilteredObservations.ToPagedList(PageNumber, PageSize));
    }

My main view

//index.cshtml
@model AF.Web.ViewModels.ObservationManagementVM
....
<div id="testsim">
  @Html.Action("indexPagedSummaries", new { data = Model.ObservationSessions })
</div>
<input id="new-view" value="Sessions" type="button" />

<script>
$("#new-view").click(function() {
   $.ajax({
     type: "GET",
     data: { data: "@Model.FeedBackSessions" },
     url: '@Url.Action("indexPagedSummaries")',
     cache: false,
     async: true,
     success: function (result) {
     console.log(result);
       $('#testsim').html(result);
       $('#testsim').show();
      }
  });
});
</script>
....

And my partial view

//indexPagedSummaries.cshtml
@model PagedList.IPagedList<AF.Services.Observations.ObservationSessionModel>
@using (Html.BeginForm("indexPagedSummaries"))
{

    <ol class="vList vList_md js-filterItems">
        @foreach (var item in Model)
        {
            @Html.DisplayFor(modelItem => item)
        }
    </ol>
    <div>
        Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

        @Html.PagedListPager(Model, page => Url.Action("Index",
                                new { page }))
    </div>
}

Html.Action() returns what I want perfectly, but it doesn't seem to be able to be triggered by a button click.

So, I'm not getting any errors, but the url doesn't give any data back. When I try to run the Observation/indexPagedSummary url without passing in data, I get a System.ArgumentNullException error, so I'm assuming that something is being transferred to the view model. Any help would be so appreciated.

Using data annotations with the help of MetadataTypeAttribute doesn't seem to be working with ASP.NET Web API Help Page. Not even sure if the data annotations actually work with MetadataTypeAttribute, but looks like it should... based on this link. We need to specify data annotations using different classes because the primary models are being used by other portable class libraries, in which these libraries cannot use the data annotations used with ASP.NET Web API.

[MetadataType(typeof(UserInfoMetadata))]
public partial class UserInfoViewModel
{
}

public class UserInfoMetadata
{
    [Required]
    [Display(Name = "Email")]
    public string Email { get; set; }
}

Looking at the sample model above, RequiredAttribute has been specified. That said, it should be displayed on the additional information column for the "Email" field or property. Specifying data annotations without using MetadataType attributes seem to be working fine.

I have setup the cultures for my views and changing the culture in a controller but I can't seem to find how to know what culture I'm currently using in a controller, I'm looking for something like:

public class HomeController : Controller {
  public async Task<IActionResult> Index()
  {
      // Something like the next line
      var requestCulture = GetRequestedCulture()
      return View();
  }
}

Thanks for all your help

I am currently creating an API which accepts the string like "sample input" as input parameter. This API should be calling other third party API passing the same value we got as the input like

https://thirdpartyhost/api/dept?name=sample+input

which returns an xml like

<lab:labs>
<lab uri="https://thirdpartyhost/api/dept/1">
<name>sample input</name></lab>
</lab:labs>

I will need to reterive the uri from the <lab uri="https://thirdpartyhost/api/dept/1"> which will give us the required response. How can I approach this. Should be calling the third party API directly in to the API I am creating and consume the response. Any help is greatly appreciated new to AsP.NET API ans kind of stuck

I've created a SearchResults control that shows the results of a search. This control has a repeating element (displaying the results) but also contains other elements which I've removed for this question.

Currently in the following example DataItem cannot be resolved. I'm trying to work out how to make DataItem resolvable so I can use this control in the following way:

<Controls:SearchResults runat="server" id="Results">
    <RowHeaderTemplate>
        <tr>
            <td>User ID</td>
        </tr>
    </RowHeaderTemplate>
    <RowItemTemplate>
        <tr>
            <td>
                <%#((Models.User)Container.DataItem).ID %>
            </td>
        </tr>
    </RowItemTemplate>
</Controls:SearchResults>

It is used in this way:

var searchResults = GetSearchResults();
Results.DataSource = searchResults ;
Results.DataBind();

Search Results Control Code:

[System.ComponentModel.DefaultBindingProperty("DataSource")]
public partial class Search : UserControl
{
    [PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(TemplateControl))]
    public ITemplate RowHeaderTemplate { get; set; }

    [PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(TemplateControl))]
    public ITemplate RowItemTemplate { get; set; }

    public IEnumerable<object> DataSource { private get; set; }

    private bool DataBindingComplete { get; set; }

    public override void DataBind()
    {
        if (DataBindingComplete) return;
        foreach (var obj in DataSource)
        {
            var newControl = new PlaceHolder();
            RowItemTemplate.InstantiateIn(newControl);
            RowItemContainer.Controls.Add(newControl);
        }
        DataBindingComplete = true;
        base.DataBind();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Visible) return;

        OnInit(e);
        if (RowHeaderTemplate != null)
        {
            RowHeaderTemplate.InstantiateIn(RowHead);
        }
    }
}

With the markup:

<asp:PlaceHolder runat="server" ID="Wrapper">

    <h2>Results</h2>    
    <table border="1">
        <asp:PlaceHolder runat="server" ID="RowHead"/>
        <asp:Placeholder runat="server" Visible='<%#TotalResults == 0 %>'>
            <tr>
                <td colspan="100">
                    No results returned!
                </td>
            </tr>
        </asp:Placeholder>
        <asp:Placeholder runat="server" ID="RowItemContainer" Visible='<%#TotalResults > 0 %>'>

        </asp:PlaceHolder>        
    </table>

</asp:PlaceHolder>

Please note this is a trimmed down example, simply using a Repeater control in place of it wont suffice.

I need to add dynamically with 3 text box field enter image description here

It works but the problem is I can't save the previews records 'cause the data table rewrite in the event the object.

 private void AgregarFila()
{
    dt.Columns.Add("Fecha", typeof(String));
    dt.Columns.Add("Documento", typeof(String));
    dt.Columns.Add("Folio", typeof(Int32));

    for (int i = 0; i <= 2; i++) // It is only for testing
    {
        dtRow = dt.NewRow();
        dtRow["Fecha"] = Session["HCfecha"];
        dtRow["Documento"] = Session["HCDocumento"];
        dtRow["Folio"] = Session["HCFolio"];
        dt.Rows.Add(dtRow);
    }
    gvHistoriaLaboral.DataSource = dt;
    gvHistoriaLaboral.DataBind();
}

View.aspx

<asp:DataGrid ID="gvHistoriaLaboral" GridLines="None" CssClass="table table-striped" runat="server"></asp:DataGrid>

help!

I'm very confused as to what is going on here. No matter what changes I make in IIS (deleting application pools, adding new pools, adding new websites etc.) I do not see a single change in the applicationHost.config file.

The files located in C:\Windows\SysWOW64\inetsrv\Config and C:\Windows\System32\inetsrv\Config are not being altered at all, in fact the names for the application pools and websites in those configuration files aren't even close to the ones in the actual IIS manager.

Is there some 3rd location where the REAL configuration file is?

I'm using a combobox on the layout view and i need to call a method on a controller when an index is changed

Here is what i have on _Layout.cshtml

        <select id="combo" OnSelectedIndexChanged="IndexChanged" AutoPostBack="True" runat="server">
                <option> xxx</option>
                <option>yyy</option>
        </select>

And i call the method on controller

 public void IndexChanged(object o, EventArgs e)
    {
        if(... ){

        }else{

        }
    }

But the program never reach the method, and i dont know why..Ideas?

I already saw other questions, but nothing works for me. I tried put the method on the view, create a method without params ... nothing works

This question already has an answer here:

When i redirect from a Controller using

RedirectToAction("Index", "Controller");

Or Generate a link with UrlHelper

@Url.Action("Index","Controller");

In both ways the "/Index" Part is striped down from my URL. Although for SEO Purposes i want my url to be displayed always at the same manner.

www.domain.com/en/Controller/Index

but now i get

www.domain.com/en/Controller

How can i force these two methods above always display the "/Index" Part.

P.S I know this happens because "Index" is indicated as a Default action on my route, but either way i want it to be displayed.

I started a Asp.net MVC project and created a main layout and created bundle css groups. Every subpage will have one more css which I need to link on the subpage. So, I bundle all the css from the main page and then the css group on the subpage. On one page it is working, on another it is not. Three hours, nothing found. When I try the code without the main layout, it's working. I tried even to create embedded css on that subpage, but even that was not working. The main css files are working, but the one included on the subpage is linked (and the link is ok) but not applied.

Main page (layout):

    @Styles.Render("~/css/main")
    @RenderSection("head", false)

Subpage:

@section head{
@Styles.Render("~/css/account") }

Bundle:

            bundles.Add(new StyleBundle("~/css/main").Include(
                    "~/assets/css/bootstrap.css",
                    "~/assets/css/metisMenu.css",
                    "~/assets/css/font-awesome.css",
                    "~/assets/css/elegant-icons.css",
                    "~/assets/css/pe-7-icons.css",
                    "~/assets/css/pe-7-icons-helper.css",
                    "~/assets/css/jquery-jvectormap.css",
                    "~/assets/css/tether-shepherd.css",
                    "~/assets/css/jstree-default.css",
                    "~/assets/css/styles.css",
                    "~/assets/css/custom.css"));

        bundles.Add(new StyleBundle("~/css/account").Include("~/assets/css/account.css"));

I'm using this template: http://wrapbootstrap.com/preview/WB051SCJ1 So, I created the layout and the subpage was account settings (Click on account and then settings).

Anybody ideas what is the problem?

Hopefully this is a easy question, i tried to do what i cound do on my own. But i can't solve the rest part.

Out for every row, i want to check if the date is heigher or lower equels to the last. But how?

As you can see yon on the image and the sample code.

Click and see the image exsample

And the following code:

@using Scoutpocket.Models.Database;
@model Tuple<List<Properties>, List<SubProperties>, List<Rating>>

<div class="container">

    @foreach (var item in Model.Item1)
    {
        <br />
        <br />
        <b>
            @item.PropertiesName
        </b>

        <br />




        foreach (var item2 in item.SubProperties)
        {
            @item2.SubPropertiesName<br />

            int count = 2;
            int getLast = 1;


            foreach (var item3 in item2.rating.Where(x => x.PlayerID == 1).Take(count).OrderByDescending(x => x.Date))
            {

                for (int i = 0; i < getLast; i++)
                {
                    // Check the index of the last row, and check if the current date is lower or heighter.


                    <b>Compare date on last and newst</b>
                }

                <span>Rating ID: @item3.RatingID</span>
                <span> | </span>
                <span>Value: @item3.Value</span>
                <span> | </span>
                <span>ScoutID: @item3.ScoutID</span>

                <span> | </span>
                <span>PlayerID: @item3.PlayerID</span>

                <span> | </span>
                <span>Date: @item3.Date</span>
                <br/>
            }

        }
    }

</div>