this is the code from Ruby on Rails Tutorial by MH:

def feed
    following_ids = "SELECT followed_id FROM relationships
                     WHERE  follower_id = :user_id"
    Micropost.where("user_id IN (#{following_ids})
                     OR user_id = :user_id", user_id: id)
end

Is this SQL safe? Because many people told me never use interpolation but use escaped code ever (with ? in this case). So is this code safe?

I need a mysql query to show the nearby products on a map that far away 9 kilometers but i want to show them chunk by chunk like the pagination functionality. for example when the map is first loaded it will be zoomed in and some products shown then when i zoom out it load the another more items also when i move(scroll) on the map on any direction like north or east it will show a lot more products until it all products are loaded.

I am working on porting some standalone code into a razor format and there is an event tied to a part of one page in this format:

<body onload='foo()'>

// content in here

</body>

Now in standalone this works fine, but in razor it doesn't work at all because the event foo () never fires in dev-tools. I found a work around by using:

<script>
    document.onreadystatechange = function () {
        if (document.readyState === 'interactive') {
            // do foo's code
        }
    }
</script>  

to kind of hack it in. But I feel like this is bad design, I've been googling around for a bit now but I can't find any related examples on attaching js events to a razor element. Why doesn't the onload event do anything? And what is the right way to do this?

When i select a folder manually, through FolderBrowserDialog, my need to substitute the path to the code below.

Where "%ProgramFiles (x86)%\MyApp" must be replaced with the variable of the selected folder + file name.

As a result, when selecting a folder, the file size "testFile.txt" in "label1" should be displayed (there will be two or more such files).

    private void button1_Click(object sender, EventArgs e)
    {
        FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
        DialogResult result = folderBrowser.ShowDialog();
        if (result == DialogResult.OK)
        {
            // Determine the size of the file in KB (dividing the number of bytes by 1024)
            FileInfo fs1 = new FileInfo(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%\\MyApp\\testFile.txt"));
            long FileSize1 = fs1.Length / 1024;
            label1.Text = "testFile.txt (" + Convert.ToString(FileSize1) + " KB)";
            if (FileSize1 > 180 & FileSize1 < 186) // If the file is larger and smaller than the specified sizes
            {
                label1.ForeColor = Color.Green;
            }
            else
            {
                label1.ForeColor = Color.Red;
            }
        }
    }

In this case can I read the values from list of leaguelist ?

 List<string[]> leaguelist = new List<string[]>();
        while (count != 0)
        {
            Int16 id = Convert.ToInt16(sportds.Tables[0].Rows[count-1]["sports_details_id"].ToString());

            using (SqlDataAdapter leagueDetails = new SqlDataAdapter("select league_name, league_details_venue,league_details_date from leagues, league_details where sports_details_id1 in ('" + id+ "') or sports_details_id2 in ('" + id + "')", sqlConnection1))
            {
                DataSet leagues = new DataSet();
                leagueDetails.Fill(leagues).ToString();

                lname = leagues.Tables[0].Rows[0]["league_name"].ToString();
                lvenue = leagues.Tables[0].Rows[0]["league_details_venue"].ToString();
                ldate = leagues.Tables[0].Rows[0]["league_details_date"].ToString();

                string[] fields = new string[3];
                fields[0] = lname;
                fields[1] = lvenue;
                fields[2] = ldate;
                leaguelist.Add(fields);                   
            }
            count = count - 1}

Please help me with this !!

I want to include country code in the url base on the client IP Address in asp.net mvc.

Scenario :

I have a company website www.example.com now and we want to expand url like below base on the client IP

www.example.com/sg/
www.example.com/au/
www.example.com/jp/ 

P.S : no language change(it is English version for all above countries). I search in stackoverflow, there are a few questions, but those are different NOT in asp.net mvc.

How can I do it.

Thank you

I am trying to load a partial view of inside a tab but its not showing data.

I am using the following code can I not just do a loop using razor code this is in a partial view which I wish to load in from another view

@model IEnumerable<solitude.models.ProductImages>


@{
    ViewData["Title"] = "ProductPicturesList";
    Layout = "~/Views/Shared/_LoginAdminLte.cshtml";
}

<h2>ProductPicturesList</h2>



<table class="table">
    <thead>
        <tr>
            <th>
               Picture Title
            </th>


            <th>
                Image
            </th>


    </thead>

    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Title)
                </td>
            </tr>


        <td>
            <a asp-action="Edit" asp-route-id="@item.ProductID">Edit</a> |
            <a asp-action="Details" asp-route-id="@item.ProductID">Details</a> |
            <a asp-action="Delete" asp-route-id="@item.ProductID">Delete</a>
        </td>

        }
        </tbody>
    </table>

Its cause in the main list I am using a view model but I want to show a list of pictures above the form upload what would my best way of doing this be as obv it is not returning anyresults I am using a controller for my main page.

@model solitude.models.Models.ViewModels.ProductImageVm 
@*
    For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
*@

@Html.PartialAsync("_ProductPicturesList.cshtml")

<div class="form-group">

 <form asp-controller="Products" asp-action="FileUpload" asp-route-returnurl="@ViewData["ReturnUrl"]" enctype="multipart/form-data" method="post" class="form-horizontal" role="form">



    <input asp-for="Title" />
    <input asp-for="ProductId" type="hidden" />
    <input asp-for="Image" />
    <input type="submit" />
</form>

Edit 2 My Product Images as a class should this be changed

public   class ProductImages
{


        [Key]
        public int ProductImageId { get; set; }

        public int ProductID { get; set; }


        public string ProductImageTitle { get; set; }
        public string ProductImageUploadUrl { get; set; }
        public string ProductImageRealPath { get; set; }

        public string ServerIpAddress { get; set; }
        public string ProductImageAltTag { get; set; }

        public int DisplayOrder { get; set; }

        public string Image { set; get; }

    }
}

Following this guide, I'm trying to show on an ASP.NET Core 2.0 page the settings values.

In startup.cs I added some services:

services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddOptions();
services.Configure<MyOptions>(Configuration);

where MyOptions is defined here:

namespace WebApplication1
{
    public class OptionsController : Controller
    {
        private readonly SubOptions _SubOptions;

        public OptionsController(IOptions<SubOptions> options)
        {
            _SubOptions = (SubOptions) options;
        }

        public IActionResult Index()
        {
            var RefreshTime = _SubOptions.RefreshTime;
            return Content($"RefreshTime = {RefreshTime}");
        }
    }

    public class MyOptions
    {
        public MyOptions()
        {
            SubOpt = new SubOptions();
        }

        public SubOptions SubOpt { get; set; }
    }

    public class SubOptions
    {
        public SubOptions()
        {
            RefreshTime = 5;
        }

        public int RefreshTime { get; set; }
    }
}

Trying from startup.cs I can access to the RefreshTime setting. Now I want to do this directly in cshtml:

@using Microsoft.Extensions.Options
@model MyOptions
@inject IOptions<MyOptions> Options
@page
@model AboutModel
@{
    ViewData["Title"] = "About";
}
<
<h3>@Model.Message</h3>
<br />
<div>
    <h3>Options</h3>
    <h4>Sub Options</h4>
    <p><b>Refresh time</b> @Options.Value.SubOptions.RefreshTime</p>
</div>

The page doesn't load but I don't see any errors in the output console of VisualStudio nor in the one of the browser.

Furthermore the page doesn't load even if I just put there the first @using directive, removing all the other options stuff.

Then I checked I have that package installed and it seems so:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
  </ItemGroup>

Is there something other I need to do?

I have a WCF application service that manages a facebook page using Graph API (it deletes all the comments in all the posts), i want this code to run whenever a comments in posted in the page, i google for solutions, some talk about asp.net webhook (i found dropbox, gethub..etc but no facebook), others talk about push notifications, others proposed to make an infinite loop (white true) with a delay of 5 minutes where the WCF check for new comments in the posts but somebody told it will not work in WCF...

Question :

How can i make my WCF application service fires a procedures whenever somebody post a new comment in my page ?


NB : +1 if i can get the id of the post where the comment had been posted, and the id of the comment.

I want to pass both model object and query string to the view so in controller action method I am creating anonymous object and passing both model object and query string as parameter to view method as shown below.

But my view is not displaying. Instead it displays my custom error page.

How to achieve this? Seems I am doing something wrong. I am pretty new to MVC. Any help would be much appreciated.

public ActionResult Index()
    {
        DBInteraction db = new DBInteraction();
        EducationInfo1 obj = new EducationInfo1();
        obj = db.retrieveEducationInfo1();

        return View("EducationInfo1",new {_obj = obj , mode ="edit",docid= "1"});
    }

Image of Code

I have created an MVC and made a post function so the user can submit text and it will appear right below.

I want to save the text and make another post above it, every time the user submits text, so i created a database called tweettable with 1 varchar attribute called tekst

In my repository i have this create method to put info into the table:

@Override
public void create(String tweet) {

    jdbc.update("INSERT INTO tweets.tweettable(tekst) " + "VALUES('" + tweet 
+ "') ");
}

This is the code i have for posting in my controller:

@RequestMapping(value = "/adminPage", method = RequestMethod.POST)
public String adminPage(@RequestParam("tweet") String input, Model model) {
    model.addAttribute("theText", input);

    userService.create(input);

    return "adminPage";
        }

This wont work, when i submit i get the whitelabel error page. It worked before i tried to put a Database on it.

Any help is appreciated!

Is it possible to alter a data from a Select SqlCommand before binding it to the asp:listview? Here is the code:

void getAudit()
{
    con.Open();
    SqlCommand com = new SqlCommand();
    com.Connection = con;
    com.CommandText = "SELECT a.AuditRID, e.EmployeeID, e.LastName, e.FirstName, a.TimeStamp, " +
        "a.Event, a.Description FROM AuditLogs a INNER JOIN Employee e ON a.EmployeeID " +
        "= e.EmployeeID ORDER BY a.AuditRID DESC";
    SqlDataAdapter da = new SqlDataAdapter(com);
    DataSet ds = new DataSet();
    da.Fill(ds, "Audit");
    lvAudit.DataSource = ds;
    lvAudit.DataBind();
    con.Close();

Description column returns an encrypted data from the Database and i would like to decrypt it before binding it to an asp:listview namely the lvAudit in my front end. Is this possible?

I want to use the ()Load method. I have done it without a problem on PHP but now I want to do the same on ASP.net.

<script>
    $(document).ready(function () {
        $("#btn").click(function () {
            $("#test").load("footershop.txt")
        });
    });
</script>

<section class="shop">
    <footer>
    <img src="@Url.Content("~/Images/klader.jpg")" alt="klader">
    <div id="test" >
        <p class="shoptext">text</p>
    </div><br />
    <button id="btn">Mejla oss</button>
    </footer>
</section>

Here is my code in ASP.net. I put the "footershop.txt" in the App_Data folder. It does not show up. Where should I put the textfile in ASP?

I am in the process of migrating a project from ASP.NET MVC 5 to ASP.NET Core 2 and have run into some issues regarding the MultipartFormDataStreamProvider

As far as I can tell it's not yet a part of .NET Core and therefore cannot be used. The issue I'm trying to solve is a part of the code where Sendgrid is beeing used, parsing of e-mails.

The .NET MVC 5 code looks as follows

[HttpPost]
public async Task<HttpResponseMessage> Post()
{
   var root = HttpContext.Current.Server.MapPath("~/App_Data");
   var provider = new MultipartFormDataStreamProvider(root);
   await Request.Content.ReadAsMultipartAsync(provider);

   var email = new Email
   {
      Dkim = provider.FormData.GetValues("dkim").FirstOrDefault(),
      To = provider.FormData.GetValues("to").FirstOrDefault(),
      Html = provider.FormData.GetValues("html").FirstOrDefault()
   }
}

This code is a snippet taken from the Sendgrid API Documentation: https://sendgrid.com/docs/Integrate/Code_Examples/Webhook_Examples/csharp.html

So I have been fiddling with this for a while, trying to come up with a solution but I'm utterly stuck. The closest to a solution I've come is to use Request.Form e.g

To = form["to"].SingleOrDefault(),
From = form["from"].SingleOrDefault()

However this only works when sending in data through the ARC REST Client plugin for Chrome (or any other REST-API tester). Also this solution won't be able to handle attachments such as images and the like.

So I'm turning to the community of StackOverflow hoping that someone has some pointers or a solution for how to migrate this to .NET Core 2.

Thanks in advance!

I have a asp.net mvc application with bootstrap and slicknav. So that the menu items will be correct rendered on different devices.

But if I render the site to a mobile format. I don't see the slicknav menu. The menu items are not shown anymore.

So my question is, how to show the menu items with slicknav?

Thank you

This is the _layout page:

<!DOCTYPE html>
<html>
<head runat="server">


    <link rel="stylesheet" href="~/Content/bootstrap.min.css">
    <link rel="stylesheet" href="~/Content/animate.css">
    <link rel="stylesheet" href="~/Content/font-awesome.css">
    <link rel="stylesheet" href="~/Content/nexus.css">
    <link rel="stylesheet" href="~/Content/responsive.css">
    <link rel="stylesheet" href="~/Content/custom.css">
    <link rel="stylesheet" href="~/Content/CustomCSS.css">



    <!-- Google Fonts-->
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Open Sans:300,400" />
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Source Sans Pro:300,400" />

    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/jquery.isotope.js"></script>
    <script src="~/Scripts/jquery.slicknav.js"></script>
    <script src="~/Scripts/jquery.visible.js"></script>
    <script src="~/Scripts/modernizr.custom.js"></script>


</head>
<body>



    <div id="body_bg">


        <!-- Background -->
        <!--End Background -->
        <!-- Logo -->






        <div id="hornav" class="pull-right">
            <ul id="hornavmenu" class="nav navbar-nav">
                <li>
                    <a href="index.html">Home</a>
                </li>
                <li>
                    <span>Features</span>
                    <ul>
                        <li class="parent">
                            <span>Typography</span>
                            <ul>
                                <li>
                                    <a href="features-typo-basic.html">Basic Typography</a>
                                </li>
                                <li>
                                    <a href="features-typo-blockquotes.html">Blockquotes</a>
                                </li>
                            </ul>
                        </li>
                        <li class="parent">
                            <span>Components</span>
                            <ul>
                                <li>
                                    <a href="features-labels.html">Labels</a>
                                </li>
                                <li>
                                    <a href="features-progress-bars.html">Progress Bars</a>
                                </li>
                                <li>
                                    <a href="features-panels.html">Panels</a>
                                </li>
                                <li>
                                    <a href="features-pagination.html">Pagination</a>
                                </li>
                            </ul>
                        </li>
                        <li class="parent">
                            <span>Icons</span>
                            <ul>
                                <li>
                                    <a href="features-icons.html">Icons General</a>
                                </li>
                                <li>
                                    <a href="features-icons-social.html">Social Icons</a>
                                </li>
                                <li>
                                    <a href="features-icons-font-awesome.html">Font Awesome</a>
                                </li>
                                <li>
                                    <a href="features-icons-glyphicons.html">Glyphicons</a>
                                </li>
                            </ul>
                        </li>

                    </ul>
                </li>




            </ul>
        </div>

        <div class="main-content">
            @RenderBody()
        </div>





        <!-- End Top Menu -->

        <div class="container no-padding">
            <!-- === END HEADER === -->
            <!-- === BEGIN CONTENT === -->
            <div class="row">
                <!-- Carousel Slideshow -->
                <div id="carousel-example" class="carousel slide" data-ride="carousel">
                    <!-- Carousel Indicators -->
                    <ol class="carousel-indicators">
                        <li data-target="#carousel-example" data-slide-to="0" class="active"></li>
                        <li data-target="#carousel-example" data-slide-to="1"></li>
                        <li data-target="#carousel-example" data-slide-to="2"></li>
                    </ol>
                    <!-- End Carousel Indicators -->
                    <!-- Carousel Images -->

                    <!-- End Carousel Images -->
                    <!-- Carousel Controls -->
                    <a class="left carousel-control" href="#carousel-example" data-slide="prev">
                        <span class="glyphicon glyphicon-chevron-left"></span>
                    </a>
                    <a class="right carousel-control" href="#carousel-example" data-slide="next">
                        <span class="glyphicon glyphicon-chevron-right"></span>
                    </a>
                    <!-- End Carousel Controls -->
                </div>
                <!-- End Carousel Slideshow -->
                <!-- Tabs -->
                <div class="tabs-dark" style="padding:0;">
                    <!-- Tab Navigation -->
                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#home" data-toggle="tab">Home</a>
                        </li>
                        <li>
                            <a href="#profile" data-toggle="tab">Profile</a>
                        </li>
                        <li>
                            <a href="#messages" data-toggle="tab">Messages</a>
                        </li>
                    </ul>
                    <!-- End Tab Navigation -->
                    <!-- Tab Panes -->
                    <div class="tab-content">
                        <div class="tab-pane fade in active" id="home">
                            <img style="float: left; margin-right: 25px; margin-bottom: 10px;" src="assets/img/frontpage/filler1.jpg" alt="filler image">
                            <h3>Humanitatis Per Seacula</h3>
                            <p>
                                Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui
                                sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem
                                modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
                            </p>
                        </div>
                        <div class="tab-pane fade" id="profile">
                            <img style="float: left; margin-right: 25px; margin-bottom: 10px;" src="assets/img/frontpage/filler2.jpg" alt="filler image">
                            <h3>Mirum Est Notare</h3>
                            <p>
                                Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui
                                sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem
                                modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
                            </p>
                        </div>
                        <div class="tab-pane fade" id="messages">
                            <img style="float: left; margin-right: 25px; margin-bottom: 10px;" src="assets/img/frontpage/filler3.jpg" alt="filler image">
                            <h3>Sollemnes In Futurum</h3>
                            <p>
                                Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui
                                sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem
                                modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
                            </p>
                        </div>
                    </div>
                    <!-- End Tab Panes -->
                </div>
                <!-- End Tabs -->
            </div>
        </div>
        <div class="container">
            <div class="row">
                <!-- Main Article -->
                <div class="col-md-12 margin-top-30">
                    <h2 class="item-title">
                        Nulla in enim quis
                    </h2>
                    <p>
                        <img class="animate fadeInRight" style="float: right;" src="assets/img/frontpage//responsive_screens.png" alt="responsive screens">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
                        lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto
                        odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
                    </p>
                    <p>
                        Mirum est notare quam littera gothica, quam nunc putamus. Cras non sem sem, at eleifend mi. Vivamus sit amet ante est, sit amet rutrum augue. Cras non sem sem, at eleifend mi. Nam liber tempor cum soluta nobis eleifend
                        option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Curabitur eget nisl a risus.
                    </p>
                </div>
                <div class="clearfix"></div>
                <!-- End Main Article -->
            </div>
        </div>
        <!-- Footer Menu -->
        <!-- End Footer Menu -->
    </div>


    @Scripts.Render("~/bundles/bootstrap")
    @Scripts.Render()

    @RenderSection("scripts", required: false)

</body>
</html>

<script>

    $(document).ready(function () {
        $('.mainNav li:has(ul)').addClass('has-child');
    });


</script>

Thank you

Consider this base64 encode image

<img src='data:image/Png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABICAYAAABhlHJbAAAABHNCSVQICAgIfAhkiAAAAAFzUkdCAK7OHOkAAAAEZ0FNQQAAsY8L/GEFAAAACXBIWXMAABVlAAAVZQGF3cVdAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAABnNJREFUeF7tnFls3EQYx11ucQshClWbtb1LC4RLIARIHAXxgsQDCOWhJGs7mypIoII4BAIhsYAEWY+TlEo8FAQSQjxAuR54AnFUFHH0CQlEEWcaQhpKmx5poVWb8H3eb92Jd7Nre8a7a2d/0l9txvN99vw1HnvtGSsdqskYzu2ayb4A7dNN9oNm2E8qPW8fT5s71EOznDwYdxQ0x0s12LtXD248kaoFpFg8TisMX6Gb9t264dwHSR5PtEz7Mc10BrE92b6RnKLMLaGWulDPO+w3ryLoje8FMlG37As1094IQX/7k6RJqsl+wdNz2WDxVDXProWyGX8dv+qamFu34WQwbz1UPOIPTLec3+HfndXltQU9+P0qE1Vr9GzY+K2/MugACAfUd8q9Mslir4M+BMO+oXb52xpYaOLq1cUTyLziKVCIJvGVtmYMdlf4gTMZ4NkGpjq+NoeTwZ51k8EA+zS/AcaG5z13U0o2zy6FtoqO8ZNKpm/0AvgP350Z7SO1kHlTXJujalqB3vZApQCvSti1aT+pJGcOdUNbZZiHegtP308qBXCJfoL2k0q6+p1LYNzbwRkgoumca /> 

I would like to post this src to Mvc controller but getting null when post with ajax here is the post method.

    var file = document.getElementById("base64image").src;

        var formdata = new FormData();
        formdata.append("base64image", file);

        $.ajax({
            url: "http://localhost:26792/home/SaveImage",
            type: "POST",
            data: file



        });

Mvc Controller

    [HttpPost]

    public void SaveImage(Image file)
    {

    }

I think the datatype I am using is not valid for this please suggest me what can I do here.

enter image description here

Full Html Code

<!doctype html>

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WebcamJS Test Page</title>
<style type="text/css">
    body { font-family: Helvetica, sans-serif; }
    h2, h3 { margin-top:0; }
    form { margin-top: 15px; }
    form > input { margin-right: 15px; }
    #results { float:right; margin:20px; padding:20px; border:1px solid; background:#ccc; }
</style>
</head>
<body>
<div id="results">Your captured image will appear here...</div>

<h1>WebcamJS Test Page</h1>
<h3>Demonstrates simple 320x240 capture &amp; display</h3>

<div id="my_camera"></div>

<!-- First, include the Webcam.js JavaScript Library -->
<script type="text/javascript" src="../webcam.min.js"></script>

<!-- Configure a few settings and attach camera -->
<script language="JavaScript">
    Webcam.set({
        width: 320,
        height: 240,
        image_format: 'jpeg',
        jpeg_quality: 90
    });
    Webcam.attach( '#my_camera' );
</script>

<!-- A button for taking snaps -->
<form>
    <input type=button id="takeshot" value="Take Snapshot" onClick="take_snapshot()">
</form>

<!-- Code to handle taking the snapshot and displaying it locally -->
<script language="JavaScript">

    window.onload = function () {

        setInterval(function () { take_snapshot() }, 5000);
    }
    function take_snapshot() {
        // take snapshot and get image data
        Webcam.snap( function(data_uri) {
            // display results in page
            document.getElementById('results').innerHTML = 
                '<h2>Here is your image:</h2>' + 
                '<img id="base64image" src="' + data_uri + '"/>';
        });



        var file = document.getElementById("base64image").src;

        var formdata = new FormData();
        formdata.append("base64image", file);

        $.ajax({
            url: "http://localhost:26792/home/SaveImage",
            type: "POST",
            data: file



        });
        //var ajax = new XMLHttpRequest();
        //ajax.addEventListener("load", function (event) { uploadcomplete(event); }, false);
        //ajax.open("POST", "http://localhost:26792/home/SaveImage");

        //ajax.send(formdata);
    }
    </script>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>


 </body>
 </html>

So i have one sql table with Primary Key(PK) couple of teams, duties and positions. I want to bind dynamically 3 dropdown lists in mvc and assign my choice from them to a personid.My issue is how i make those lists and not the assignment process. I tried to pass SelectedValue from team dropdownlist to Duties Dropdownlist with no success.Any suggestions?

╔═════════════════════════════════════╗
║ PK TEAM  DUTIES  POSITION  PERSONID ║
╠═════════════════════════════════════╣
║ 1   T1   D1      P1        ID1      ║
║ 2   T1   D2      P2        ID2      ║
║ 3   T2   D1      P3        ID3      ║
║ 4   T2   D2      P4        ID4      ║
║ 5   T2   D3      P5        ID4      ║
║ 6   T3   D1      P2        ID5      ║
╚═════════════════════════════════════╝

suppose i want to consume a web service say https://openweathermap.org/api in my web application project then does it requires that I have followed MVC architecture means is consuming of a web service possible only when we have followed mvc. I am thinking of the ans as yes because the implementation of this service can't be done by me so not using mvc is not a option here.

Hello i have two models called channels and programs.. im showing the dropdown of channels and all i want is that when i select any channel , the view will show the programs of specific channel.. Problem is when i select any channel, it takes the value of channel and return it to the controller and apply filtering logic and pass the data to the new View..Although view is executing all values properly but on browser it is not visible.. any help would be grateful..

View Code:

 @model SitefinityWebApp.Mvc.Models.Channel
        @Html.DropDownListFor(m => m.Title, Model.Items, "Select Channel-", new { @id = "ddl" })
    <div id="myddl">        
    </div>    
    <script>    
        $('#ddl').change(function () {
    var selectedValue = $('#ddl').val();
    $.post('@Url.Action("GetProgramByChannel", "Channels")', { selection : selectedValue }, function (data) {

    });
        });
        </script>

GetProgramByChannel Method Taking the selected value

public ActionResult GetProgramByChannel(string selection)
        {
            var model = new ProgramsModel();
            return View("ProgramsByChannel", model.GetChildItemsOfChannel(selection));
        }

ProgramsByChannelView

@model SitefinityWebApp.Mvc.Models.Channel


<div id="ddl">
    @foreach (var item in Model.Programs)
    {
        @Html.DisplayFor(m => item.Title) <br />

        @Html.DisplayFor(m => item.ShortDescription) <br />

        @Html.DisplayFor(m => item.LongDescription) <br />
    }
</div>

First, I save the frames of a tiff into a list of bitmaps:

public Bitmap SaveTiffAsTallPng(string filePathAndName)
{
    byte[] tiffFile = System.IO.File.ReadAllBytes(filePathAndName);
    string fileNameOnly = Path.GetFileNameWithoutExtension(filePathAndName);
    string filePathWithoutFile = Path.GetDirectoryName(filePathAndName);
    string filename = filePathWithoutFile + "\\" + fileNameOnly + ".png";

    if (System.IO.File.Exists(filename))
    {
        return new Bitmap(filename);
    }
    else
    {
        List<Bitmap> bitmaps = new List<Bitmap>();
        int pageCount;

        using (Stream msTemp = new MemoryStream(tiffFile))
        {
            TiffBitmapDecoder decoder = new TiffBitmapDecoder(msTemp, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
            pageCount = decoder.Frames.Count;

            for (int i = 0; i < pageCount; i++)
            {
                System.Drawing.Bitmap bmpSingleFrame = Worker.BitmapFromSource(decoder.Frames[i]);
                bitmaps.Add(bmpSingleFrame);
            }

            Bitmap bmp = ImgHelper.MergeImagesTopToBottom(bitmaps);

            EncoderParameters eps = new EncoderParameters(1);
            eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 16L);
            ImageCodecInfo ici = Worker.GetEncoderInfo("image/png");

            bmp.Save(filename, ici, eps);

            return bmp;
        }
    }
}

Then I pass that list of bitmaps into a separate function to do the actual combining:

public static Bitmap MergeImagesTopToBottom(IEnumerable<Bitmap> images)
{
    var enumerable = images as IList<Bitmap> ?? images.ToList();
    var width = 0;
    var height = 0;

    foreach (var image in enumerable)
    {
        width = image.Width > width
            ? image.Width
            : width;
        height += image.Height;
    }

    Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format16bppGrayScale);                                      

    Graphics g = Graphics.FromImage(bitmap);//gives Out of Memory Exception

    var localHeight = 0;
    foreach (var image in enumerable)
    {
        g.DrawImage(image, 0, localHeight);
        localHeight += image.Height;
    }

    return bitmap;                     
}

But I usually get an Out of Memory Exception, depending on the number of frames in the tiff. Even just 5 images that are around 2550px by 3300px each are enough to cause the error. That's only around 42MB, which ends up saving as a png that is a total of 2,550px by 16,500px and is only 1.5MB on disk. I'm even using this setting in my web.config: <gcAllowVeryLargeObjects enabled=" true" /> Other details: I'm working on a 64bit Windows 7 with 16GB of RAM (and I normally run at around 65% of ram usage), and my code is running in Visual Studio 2013 in an asp.net MVC project. I'm running the project as 32 bit because I'm using Tessnet2 which is only available in 32 bit. Still, I figure I should have plenty of memory to handle much more than 5 images at a time. Is there a better way to go about this? I'd rather not have to resort to paid frameworks, if I can help it. I feel that this is something I should be able to do for free and with out-of-the-box .net code. Thanks!

my razor view is accepting a model ... and I have this code in it ..

@{
    var my_value = "wth";
    if (Model.app != null)
    { my_value = Model.app.name; }
}

@Html.TextBoxFor(a => a.app.name, new { @Value = my_value })

shows 'wth' when the model isn't null ... did some debugging to see if my_value is set properly ... hmmm