I am currently working on a final year project in .net MVC. When i open Location_new (Action in LocationController) and click on submit then it shows error

"

Column name or number of supplied values does not match table definition.

"

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Column name or number of supplied values does not match table definition.

Source Error:

Line 22: Line 23: conn.Open(); Line 24: int count = command.ExecuteNonQuery(); Line 25: conn.Close(); Line 26:

Source File: C:\Users\Dev D\Documents\Visual Studio 2015\Projects\MySafar\MySafar\Models\DBUtility.cs Line: 24

Location.cs (Model class for query)

public class Location
    {
        public int LocationID;
        public string LocationName;
        public string PhotoPath;
        public string Details;
        public string CityID;

        public int Insert()
        {
            string query = "Insert Location VALUES(@LocationName, @PhotoPath, @Details, @CityID)";
            List<SqlParameter> parameters = new List<SqlParameter>();
            parameters.Add(new SqlParameter("@LocationName", this.LocationName));
            parameters.Add(new SqlParameter("@PhotoPath", this.PhotoPath));
            parameters.Add(new SqlParameter("@Details", this.Details));
            parameters.Add(new SqlParameter("@CityID", this.CityID));

            return DBUtility.ModifyData(query, parameters);
        }

DBUtility.cs (Model class for database)

public class DBUtility
    {
        public static int ModifyData(String query, List<SqlParameter> parameter)
        {
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=\"C:\\Users\\Dev D\\Documents\\Visual Studio 2015\\Projects\\MySafar\\MySafar\\App_Data\\MySafarDB.mdf\";Integrated Security=True";

            SqlCommand command = new SqlCommand();
            command.Connection = conn;

            command.CommandText = query;
            command.Parameters.AddRange(parameter.ToArray());

            conn.Open();
            int count = command.ExecuteNonQuery();
            conn.Close();

            return count;
        }

AdminController

public ActionResult Location_New()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Location_New_Submit()
        {
            Location l = new Location();
            l.LocationName = Request.Form["LocationName"];
            l.PhotoPath = Request.Form["PhotoPath"];
            l.Details = Request.Form["PhotoPath"];
            //l.CityID = Convert.ToInt32(Request.Form["CityID"]);
            l.CityID = Request.Form["CityID"];

            l.Insert();

            return RedirectToAction("Location_List");
        }

[HttpPost]
        public ActionResult Location_List()
        {
          return View();
        }

I am doing a school application in which i have a form through which the details regarding the particular student going for admission are entered. And there is a select form field called sibiling, which means the student who is making admission at present say student X, already has own sibling and say Student Y (brother/sister already made admission and studying from past) in which while making admission of student X , through the select option Student Y was selected and hence the parents were same for both it will be automatically gets filled in the respective input boxes and the particular sibling id gets posted into database.

The code of above process was,

Controller:

    function create() {
      $sibling_id = $this->input->post('sibling_id');

      if (isset($sibling_id)) {
      $countsib = 0;
      $up_record = 0;
      $record_value = "";
      $findusers = $this->user_model->read_user();
      // print_r($findusers);
      $find = $sibling_id;
      foreach ($findusers as $key => $value) {
        if ($value->childs != "") {
          print_r("value->childs " . $value->childs . "<br>");
          $childs = explode(",", $value->childs);
          foreach ($childs as $k_child => $v_child) {
            if ($find == $v_child) {
              print_r("find: " . $find . "<br>" . "v_child ". $v_child . "<br>");
              $up_record = $value->id;
              $record_value = $value->childs;
              $countsib = 1;
              print_r( " up_record :" . $up_record . " <br> " . " record_value :" . $record_value . "<br>" . " count :" . $countsib . "<br>" );
              break;
            }
          }
        }
      }
      if ($countsib != 0) {
        $json = array($insert_id);
        $da = array_merge((array) $record_value, (array) $json);
        $rec = implode(",", $da);
        print_r ("rec" . $rec);
        $data_parent_login = array(
          'id' => $up_record,
          'childs' => $rec
        );
        $ins_id = $this->user_model->add($data_parent_login);
      } else {
        $parent_password = $this->role->get_random_password($chars_min = 6, $chars_max = 6, $use_upper_case = false, $include_numbers = true, $include_special_chars = false);
        $temp = $insert_id;
        $data_parent_login = array(
          'username' => $this->parent_login_prefix . $insert_id,
          'password' => $parent_password,
          'user_id' => $insert_id,
          'role' => 'parent',
          'childs' => $temp
        );
        $ins_id = $this->user_model->add($data_parent_login);
      }
    }
    }

View:

<div id='sibling_id'> <span id="sibling_name" class="label label-success "><?php echo set_value('sibling_name'); ?></span></div>

Everything works fine here, but there is an option to upload csv file where the bulk details are imported..

Here if i import every respective columns and tables are stored in the database.

But i am in the need of sibling details also need to be stored in the database,

I have tried with the following for that,

Controller:

function import_student_admission() {
$father_name = $result[$i]['father_name'];
$mobile_number = $result[$i]['mobileno'];
$student_sibling = $this->student_model->get_student_by_mobileno_fathername($father_name,$mobile_number);

    if (isset($student_sibling)) {
      $countsib = 0;
      $up_record = 0;
      $record_value = "";
      $findusers = $this->user_model->read_user();
      // print_r($findusers);
      $find = $student_sibling;
      foreach ($findusers as $key => $value) {
        if ($value->childs != "") {
          // print_r("value->childs " . $value->childs . "<br>");
          $childs = explode(",", $value->childs);
          foreach ($childs as $k_child => $v_child) {
            if ($find == $v_child) {
              print_r("find: " . $find . "<br>" . "v_child ". $v_child . "<br>");
              $up_record = $value->id;
              $record_value = $value->childs;
              $countsib = 1;
              print_r( " up_record :" . $up_record . " <br> " . " record_value :" . $record_value . "<br>" . " count :" . $countsib . "<br>" );
              break;
            }
          }
        }
      }
      if ($countsib != 0) {
        $json = array($insert_id);
        $da = array_merge((array) $record_value, (array) $json);
        $rec = implode(",", $da);
        print_r ("rec" . $rec);
        $data_parent_login = array(
          'id' => $up_record,
          'childs' => $rec
        );
        $ins_id = $this->user_model->add($data_parent_login);
      } else {
        $parent_password = $this->role->get_random_password($chars_min = 6, $chars_max = 6, $use_upper_case = false, $include_numbers = true, $include_special_chars = false);
        $temp = $insert_id;
        $data_parent_login = array(
          'username' => $this->parent_login_prefix . $insert_id,
          'password' => $parent_password,
          'user_id' => $insert_id,
          'role' => 'parent',
          'childs' => $temp
        );
        $ins_id = $this->user_model->add($data_parent_login);
      }
    }
}

And model:

public function get_student_by_mobileno_fathername($father_name, $mobile_number) {
  $this->db->select()->from('students');
  $this->db->where('father_name',$father_name);
  $this->db->where('mobileno',$mobile_number);
  $query = $this->db->get();
  echo $this->db->last_query() . "<br>";
  return $query->result_array();
}

In this model i am getting the result of father name and mobile number of that particular student, and i am trying here is while importing the csv file, if the father name and mobile number are equal and the same details is there in more number of times then we can calculate that as sibling id. But i am unable to achieve it.

My understanding is that the Razor markup will encode html strings, but I tried testing it out with following code in MVC view and it did not encode the html strings.

While the first encoded string is behaving correctly since its not handled by Razor engine, but the second string is not being encoded by Razor, and also the <> part at start in last string is not being encoded by Razor.

Question : Why are second and third strings not being encoded by Razor, or am I missing something about how Razor renders html strings?

Razor markup in a MVC View

&lt;script type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
<br />
@("<script type='text/javascript'></script>")
<br />
@("<>&lt;script type=&quot;text/javascript&quot;&gt;&lt;/script&gt;")

Rendering of above Razor markup

Razor not encoding html

Please help.

i have one table like this

sn     | date      | status    | 
001    | 2017-01-01| work      | 
001    | 2017-01-02| work      | 
001    | 2017-01-03| work      |
001    | 2017-01-04| work      |
002    | 2017-01-01| sick      |
002    | 2017-01-02| sick      |
002    | 2017-01-03| sick      |
002    | 2017-01-04| sick      |
003    | 2017-01-01| work      |
003    | 2017-01-02| work      |
003    | 2017-01-03| work      |
003    | 2017-01-04| work      |

i want to show the table to my view like this

<table border="1">
    <tr>
    <td>sn</td>
    <td>01</td>
    <td>02</td>
    <td>03</td>
    <td>04</td>
    </tr>
    <tr>
    <td>001</td>
    <td>work</td>
    <td>work</td>
    <td>work</td>
    <td>work</td>
    </tr>
    <tr>
    <td>002</td>
    <td>sick</td>
    <td>sick</td>
    <td>sick</td>
    <td>sick</td>
    </tr>
    <tr>
    <td>003</td>
    <td>work</td>
    <td>work</td>
    <td>work</td>
    <td>work</td>
    </tr>
    </table>

how to write code models and controller for this case. very confused for this case.

i just create models like this

function attendance()
    {
        $this->db->select('*');
        $this->db->from('mytable');;
        $query=$this->db->get();
        return $query;
    }

and my controller like this

function get_attendance()
    { $this->m_human_capital->attendance($lab_slct)->result();
        $this->template->display('myview',$data);
    }

thank you so much for the answer.

In my MVC view, I have a country list which is populated with all the countries. This works ok and the user selects different countries & they are displayed ok. I want the ability in Javascript to change that field back to "Select Country", how do I do this?

This is in my view

<div class="form-group">
    @Html.DropDownListFor(model => model.country, ViewBag.countrylist as SelectList, "Select Country", htmlAttributes: new { @id = "ddlcountry" })
</div>

This is my javascript

$("#ddlcountry").val(44);    //this works to set the country code to 44
$("#ddlcountry").val("Select Country");    //this does not work to display "Select Country" like the default when you first load the page

How can I have the default of "Select Country" show again?

Up at top of my view:

@{
ViewData["Title"] = @Html.DisplayFor(model => model.SETitle);
ViewData["Description"] = @Html.DisplayFor(model => model.SEDescription);

ViewData["canonical"] = String.Concat("https://example.com/", Html.DisplayFor(model => model.CategoryURL), "/", Html.DisplayFor(model => model.URLSlug));

}

This renders in the browser like so:

<link rel="canonical" href="https://example.com/Microsoft.AspNetCore.Mvc.ViewFeatures.StringHtmlContent/Microsoft.AspNetCore.Mvc.ViewFeatures.StringHtmlContent">

I am using a standard asp.net core template. And it seems like this will always occur if you are concatenating multiple variables together for a ViewData[] string. What do I need to change about my syntax to get this actual values to pass through and render in my browser?

So I have a .NET Core app using razor views and certain components within my razor pages are rendered using react. I'm trying to automate my build process using cake. So step 1 is using cake to run the create-react-app npm build and generate the react bundle.js and bundle.css.

Because these generated scripts and stylesheets have random hashes attached to them I need a way to automate injecting the generated bundle.js and bundle.css in my index.cshtml script section and style section respectively.

So something like this:

<environment names="Staging,Production">
    <script src="~/static/js/main.xxxxxxxxx.js"></script>
</environment>

where x is the randomly generated hash

Edit: Cake is just basically a way to write automation scripts using c# so knowledge of cake is not required. I'm just looking for a way to do this using .NET and razor pages

We are trying to removed SqlMembership and implement ASP.NET Identity in one of our applications.

Everything works fine in HTTP, but when the site is running as HTTPS, the authentication cookie is not getting created and user keeps getting redirected back to the login page.

Is there something we need to see in order to use ASP.NET Identity Cookie Authentication in HTTPS?

app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/User/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    OnValidateIdentity = SecurityStampValidator
                        .OnValidateIdentity<ApplicationUserManager, ApplicationUser, long>(
                            validateInterval: TimeSpan.FromMinutes(20),
                            regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
                            getUserIdCallback: (id) => id.GetUserId<long>())
                }
            });

I am making an app and I need to authenticate users. I am trying to implement the best practices and to make my code as readable as posible.

I have my controller that receives the credentials from the browser via post request

I sanitize the data I receive. Until here I have no doubts

My question is authentication should be done in the model or in this controller?

I mean that I have a function in the model that returns true if the user is authenticated and receive this with the controller.

function post_signin(req, res) {

validate_data(req) // sending pointer of 'req'
const errors = req.validationErrors()

if(errors) {
    console.log(errors)
    res.end('INVALID DATA')
    return;
}

let { username, password } = req.body

username = username.toLowerCase()
 // User Model
if( !User.authenticate(username, password) ) {
    res.end('No Authenticated')
}
else {
    res.end('No Authenticated')
}

}

Thanks :-)

I have been working with Oracle SQL for a while and am currently developing an MVC application in my spare time. At the moment I stuck on an INNER JOIN lambda expression, I have no idea how to convert the SQL statement to C# lambda expression, I've had a look at other answers similar to this question but none provide the answer and a detailed description of how to convert the statement.

Code:

SELECT 
    t.name, t.description
FROM
    TOPICS t
INNER JOIN
    TOPIC_SUBSCRIPTIONS
        ON
    t.TOPICID = TOPIC_SUBSCRIPTIONS.TOPICID
WHERE
    TOPIC_SUBSCRIPTIONS.MEMBERID = 96;

I'm trying to imitate the behavior of flash messages in native PHP, for one-time display of error messages.

Displaying the Login page:

public function showLoginAndRegistrationPage()
{
    $session = new Session();

    $data['errors']['login']['account'] = $session->getFormErrorFlashData('login', 'account');

    $this->viewPresenter->display('basic', 'customer/login-registration', $data, 'Login/Register');
}

Verifying the login details:

public function processLogin()
{
    // Some code
    $session        = new Session();

    if($this->formInputFilter->isValid()) {

    // Some code

        if(true) {
    // Some code
        } else {
            $errors = array(
                'account' => 'Account does not exist.'
            );
            $session->setFormErrorFlashData('login', $errors);

            header('Location: /login');
        }
    } else {
        // Some code
    }
}

For setting the error messages:

public function setFormErrorFlashData($form, $errors = array())
{
    foreach($errors As $field => $message) {
        $_SESSION['errors']["{$form}"]["{$field}"] = $message;
    }
}

For getting the error messages stored in the session:

public function getFormErrorFlashData($form, $field)
{
    if(isset($_SESSION['errors']["{$form}"]["{$field}"])) {
        $message = $_SESSION['errors']["{$form}"]["{$field}"];

        unset($_SESSION['errors']["{$form}"]["{$field}"]);

        return $message;
    }
}

Basically for an invalid attempt, after redirect, it should now display the 'Account does not exist' message, and then when the user refreshes the page, it should no longer be there.

What happens is when I comment out the unset() line in getFormErrorFlashData(), the $_SESSION contains the errors, but of course as expected they do persist even after countless page refreshes.

But when it's not commented out, I get a NULL. It seems that $message is also unset, even after attempting to store in it the value of that session key.

I have a bootstrap file that has the session_start() line, it's loaded for every page so I doubt that's the cause?

I've looked at many posts and all of them made a hyperlink with either datafield in it, by datatextfield() or similar.. or called eval from backend. I didn't do neither of that, so I tried doing every thing I could but it didn't work. CommandField, HyperLinkeField, HyperLink, .. all didn't work.

The main point is that the data comes out fine, but I can't seem to make it hyperlink. Is it impossible to have a hyperlink this way?

I'm trying to make a hyperlink on gridview. The thing is that the column I'm trying to make the hyperlink doesn't get data from the datafield.

It gets it by onRowDataBound method of gridview something like this..

<asp:GridView runat="server" ID="someGrid" CellPadding="10" 
    DataKeyNames="idx" AutoGenerateColumns="false"
    selectMethod="someGrid_GetData" ItemType="someTable"
    updateMethod="someGrid_UpdateItem" AutoGenerateEditButton="true"
    deleteMethod="someGrid_DeleteItem" AutoGenerateDeleteButton="true"
    onRowDataBound="someGrid_RowDataBound">
    <Columns>
        <asp:BoundField DataField="thing1" HeaderText="thing1" />
        <asp:BoundField DataField="thing2" HeaderText="thing2"/>
        <asp:DynamicField DataField="poDate" DataFormatString="{0:d}" />
        <asp:BoundField HeaderText="vendor" />
        <asp:CommandField HeaderText="sku" ShowSelectButton="true" SelectText="{0}" ButtonType="Link"/>
    </Columns>
</asp:GridView>

and on the code background, it goes like this..

    protected void soGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {  
        using (soAction soa = new soAction())
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string s = e.Row.Cells[2].Text;
                string thin1 = soa.get_thin1(s);
                e.Row.Cells[4].Text = thin1;

                string thin2 = soa.get_thin2(s);
                e.Row.Cells[5].Text = thin2;
            }
        }
    }

Thanks!

Ok, so I have quite a task here:

The background of this project is very complex and fully covered by NDA's so I'll just state what I am trying to do without the background.

So what I need is a way to record every request made to an MVC application and every response from it.

Furthermore, I also need a way to "reply" the requests exactly as they were sent.

I was hoping that I could create some solution that "loads" the MVC application, Self hosts or runs in IIS, get requests, records them and passed them verbatum to the MVC application which would then act exactly like any other MVC app.

I could then create a second solution that "loads" the MVC app but instead of opening it up to request it would read the events from the event store and "replays" them in the MVC app.

Now I have no clue where to even start. This kinda think is way out of my comfort zone.

If there is another solution for how I can record and replay request (and responses) then please let me know.

Even if there is a way to intercept a request in MVC before it starts doing all of its authentication and routing malarkey then that would be a great starting point. I would also need to know where I can capture the response at the very last second before it is sent.

Many thanks for your time Andy

we are using subdirectories in our projects no separete views and controllers but in models we didn’t learn yet. Recently I’ve found this https://github.com/cakephp/cakephp/issues/60451 and actually routes and plugins we are already using, we just want to separete our models like this:

Model
-Entity
–Financial
—Money.php
-Table
–Financial
—MoneyTable.php

I’ve tryed put like this then controller is not able to find his model. How can I do to organize it, and make it work?

Things that we've tried: Use $this->setAlias('TableModel'); Call in controller:

$this->TableModel = $this->loadModel('Subfolder/TableModel'); 

didn't work for SQL build, and other classes.

My Microsoft office 365 ProPlus freeze while try to open word document from sharepoint url in my asp.net application.

In my application while track request, I have seen success "HEAD" and "OPTIONS" header. After the success not loading word file and it freezed Office 365.

Advance Thanks.

the idea in my code is to return the view from HTTP request to the client and keep executing the code (for some 10-20 seconds), thus allowing the page returned to the client to inquire of the status of the job execution by AJAX. So, it's a kind of "background" task, but very short, and with the only goal to keep the user interface responsive and display messages as the job progresses. I've read a ton of articles on the subject, and here is what I have now (the code is abbreviated to only the important parts):

public MyController(ApplicationDbContext _db)
{
    private readonly ApplicationDbContext db;

    public MyController(ApplicationDbContext _db)
    {
        db = _db;
    }

    public IActionResult Test1()
    {
        Exec(); // compile warning CS4014, since the call is not await-ed
        return View();
    }

    public IActionResult Test2()
    {
        System.Threading.ThreadPool.QueueUserWorkItem(delegate { Exec(); });
        return View();
    }

    public async Task Exec()
    {
        try
        {
            await db.Employee.ToListAsync();
        }
        catch (Exception ex)
        {
            ;
        }
    }
}

In the action Test1 I use a non-awaited async call, and it allows the execution to continue while the called function is being executed - no obvious errors here.

The action Test2 doesn't work because ApplicationDbContext in the Exec method will already be disposed of, and an exception will occur.

I wonder which is the correct way to acomplish this task and if it's possible to have ApplicationDbContext still avaiable when using the second option.

Also, even if the first option works, I'd like to have some explanation why does it work (I know it sounds a little funny, but I'd like to know that the principle applied will be working under any condition, not just in this one particular case).

I have a report viewer control in my web application project which is trying to render some rdlc reports. When i run my application a browser window (IE11) opens and shows a report viewer control Menu/Header (See screenshot below). I click the 'floppy disk icon' to save as pdf. The PDF looks perfect. I want the report to be shown in the report viewer. Any thoughts ?

Report viewer not rendering report

I am running IE 11 solution is targeting .Net 4.5.2 SQL Server 2016

I have tried the following so far with no luck

1) Added localhost to compatability view 
2) Changed the config file as per the last post in the below link

https://social.msdn.microsoft.com/Forums/en-US/7f07087b-ff38-4c3d-943f-80d56a6da369/2010-reportviewer-control-not-rendering-in-internet-explorer-when-sizetoreportcontent-false?forum=vsreportcontrols

3) Changed the config file as per the marked answer (AsyncRendering was throwing exception so not added) in the below link

ReportViewer control not displaying reports

4) Updated the assemblies as per the below link

https://docs.microsoft.com/en-us/sql/reporting-services/application-integration/integrating-reporting-services-using-reportviewer-controls-get-started

I'm making complex form And I want to use multiple (different) dropzone.js in order to upload files.

Here is how I made:

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
... form elements...
<div id="files" name="files" class="dropzone"></div>
}

And the JS:

Dropzone.options.files = {
    autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 100,
    maxFiles: 100,

    paramName: "file", // The name that will be used to transfer the file
    maxFilesize: 8, // MB
    url: "/pathToAction"
};

I want to send files and data of the form at the same time, all mapped to an object to the controller but dropzone needs to have the "url" in order to accept file upload... How to fix this? Maybe I can get the url of the form element and put it into the url parameter? Is there a best way to doing that?

Thanks in advance

This question already has an answer here:

I have the following code

@Html.LabelFor(model => model.UserRole)
@Html.DropDownListFor(model => model.UserRole, new List<SelectListItem>
{
    new SelectListItem { Value = "Manager(SDD)" , Text = "Manager(SDD)" },
    new SelectListItem { Value = "Manager(QA)" , Text = "Manager(QA)" },
    new SelectListItem { Value = "Manager(Operations)" , Text = "Manager(Operations)" },
    new SelectListItem { Value = "Team Lead(SDD)" , Text = "Team Lead(SDD)" },
    new SelectListItem { Value = "Team Lead(QA)" , Text = "Team Lead(QA)" },
    new SelectListItem { Value = "Team Lead(Operations)" , Text = "Team Lead(Operations)" },
    new SelectListItem { Value = "Lead Developer(SDD)" , Text = "Lead Developer(SDD)" }
}, "Select one", new { @class = "form-control" })

Existing Role: ( @ViewBag.erole )`

Now i just want the DropDownlist's default list item to be the one returned from database, which is placed in ViewBag.erole.

I try to add a loginform to my website. here in this code i try to check if the entered password is right.

            MySqlDataReader reade = sqlcmd2.ExecuteReader();

            var stretch = "";
            var algo = "";
            var salt = "";
            var hash = "";

            while (reader2.Read())
            {
                stretch = reader2["stretch"].ToString();
                algo = reader2["algo"].ToString();
                salt = reader2["salt"].ToString();
                hash = reader2["hash"].ToString();
            }

            reader2.Close();

            if (PasswordSecurity.PasswordStorage.VerifyPassword(passwort, 
            algo + ":" + stretch + ":18" + salt + ":" + hash))
            {
                login = true;
            }

but when i run the program i get the error-message fields are missing from the password hash.

my entries in the database:
Algo='sha1',
Stretch= 123456789,
Hash='yxcvbnmasdfg123456789012',
Salt='qwertzuiopasdfgh1234567890123456'

i dont know what specific values you would put in for hash,stretch,etc. just oriented on the type (e.g. char length:24)
thanks in advance for answering

I am trying to create my first web app. I have list of products and I want to sort products by name or price. The possible option I have in <select> tag and I try to use method onchange to send paramteres to my controller and there sort my list of products. When I debug my program I saw that as paramteres is send null value. Have you got some idea how can I resolve my problem?

<p>Sort by:</p>

<select onchange="location = this.value">
   <option value="@Url.Action("SortByString", new { id = "-----" })">-----</option>
   <option value="@Url.Action("SortByString", new { id = "Name" })">Name</option>
   <option value="@Url.Action("SortByString", new { id = "Price" })">Price</option>
</select>

public ActionResult SortByString(string sort){}

And as paramter sort is send null. Thanks.