.NET MVC

399

Solutions

298

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

Share tech news, updates, or what's on your mind.

Sign up to Post

I want to use MVC identity 2.0 with my new project. However, I think it is over-kill what I need. and I want to have super simple way to handle login/password and other simple requirements i have. so I have the following list and it is my requirement. I just need very basic membership security.

1. Each controller have a way to reflect base on the roles (admin, buyer, seller and etc.)
2. No need for any external single sign on such as facebook
3. Flexible way to add security question for member profile
4. all data stores in MS SQL, not app data / table database.

Thanks
0
do you know there is any credit card device I can connect to the phone or tablet that can allow me to scan the credit card and pop the credit card information on the webpage on mvc razor?
0
Hello;
I have small archiving web app C# MVC, and I need to have a button on this page to start a scanner direct, and get the images to store it in my sql database.
Any help please to do so!
Thanks in advance
0
I have been google cms that have mvc razor way to write codes.
so far, dnn is the best to me.

just want to see any developers found any good ones...

my requirements is simple. just easy to integrate is good enough.
0
I am using ASP.NET MVC 5 with entity framework 6 and a SQL 2014 database to create a customer relationship management system. I want to add the capability to upload and download attachments to the meeting. With the code below, I have a browse button and can browse to the files, but it is not saving to the folder in the Solution and is not saving the path to the database.

In my mind, The create view of the MeetingsController creates the meeting and allows uploading attachments. The Meeting Details view shows the meeting information as well as a link to download the related attachments. This is working off of an existing database that was used for a desktop application. I want to make this a website for my end users. I used database first methodology to create the scaffolding for controllers and views.

Here is the HttpPost for the Create action in the MeetingsController:

 [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Id,InteractionDate,Notes,approval_status_id,CustomerCallDecisionedBy,CustomerCallDecisionDate,BankOfficer,TrustOfficer,Customer,Employee,IsDeleted,IsReview")] Meeting meeting, HttpPostedFileBase upload)

        {
            if (ModelState.IsValid)
            //Add upload capability to the create meeting view
            {
                List<Attachment> attachments = new List<Attachment>();
                for (int i = 0; i <Request.Files.Count; i++)
                {
                    var 

Open in new window

0
Hi Experts,
I have the following code.
StreamReader reader = new StreamReader(response.GetResponseStream());
string data = reader.ReadToEnd();

Open in new window


After I run "data" contains the following string
"results": [{
		"url": "https://www.zoo.com/api/chats/1906.2302191.RT8CHwd45iRXZ",
		"timestamp": "2019-06-11T23:22:33Z",
		"preview": "how can I add co workers to my account?\n",
		"type": "offline_msg",
		"id": "1906.2302191.RT8CHwd45iRXZ"
	}, {
		"url": "https://www.zoo.com/api/chats/1906.2302191.RT7kr6Nkhjk52",
		"timestamp": "2019-06-11T21:33:34Z",
		"preview": "I would like to order printer",
		"type": "offline_msg",
		"id": "1906.2302191.RT7kr6Nkhjk52"
	}
}]

Open in new window


I need help to extract all the IDs in a list or array.

For example, "1906.2302191.RT8CHwd45iRXZ", "1906.2302191.RT7kr6Nkhjk52"...
I am using C# and MVC
Thanks in advance!
1
I'm making a simple call to a function in the onclick event of my input control. This same kind of call works on a different view in my project but my call is throwing an: "Object doesn't support this property of method" error message. Why is this happening?

<input type="submit" value="Back" name="btnBack" class="button" onclick="IsFormDirty()" />
.
.
.
        function IsFormDirty() {
            alert("test");
        }

Open in new window

0
Hi,
I am searching a solution to get the multiple table set from stored procedure using edmx entity framework. I found the below solution but that uses ADO.net. Is there any approach/sample code to get dataset(multiple tables) from stored procedure without ADO.

https://github.com/KrisJohnstone/RandomCodeSamples/tree/master/MultipleResultSets
Below are the project specifications:
.Net Framework: 4.7.1
VS2017
SQLServer2016
MVC: 5.2
0
I have a web app that is multi tenant

There is a select (dropdown) in the layout.cshtml
This contains a list of locations

When you select a different location, it reloads the page and populates data relevant to that location by appending a parameter
i.e.
?siteId=4

Open in new window


This is all working fine
There are many different pages in the navigation (Li's in  layout.cshtml)

The issue is, the siteId is forgotten when i visit a new page, and just loads the default site (first one in list)
I was thinking of storing this siteId in session and referring to this,
I'm wondering if there is another solution?
0
I have a layout.cshtml which all pages use

I have a HTML SELECT on this layout
When someone changes the drop down, it fires this code

   $('#sitesDdlLayout').on('change', function () {

                        var selectedSiteId = $("#sitesDdlLayout option:selected").val();

                         $.ajax({
                            type: "POST",
                             url: "@Url.Action("RedirectToSiteById", "Home")",
                            data: "{'SiteId':'" + selectedSiteId + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (response) {

                                window.location.href = response.Url;

                            }
                         });
                });

Open in new window


Then it fires this
   [HttpPost]
        public ActionResult RedirectToSiteById(string SiteId)
        {
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Home", new { SiteId = SiteId });
            return Json(new { Url = redirectUrl });
        }

Open in new window


This works fine, apart from always redirecting to the INDEX page

What I want to do is to reload the current page, and pass in query string of SITEID into the URL which will then pull in the correct content based on the site

i,e, something like this
 
       $('#sitesDdlLayout').on('change', function () {

                        var selectedSiteId = $("#sitesDdlLayout option:selected").val();
                      ....
                        url: "@Url.Action("CURRENTPAGE", "Home", URLPARAMETERHERE)",
                      ....

Open in new window


the idea is the user stays on same page,  but its reloaded with the correct SiteId appended to the URL
Any ideas the best way to do this inside the layout.cshtml file?
0
We just start using Azure to host our website and our 20 sub domains. All of the websites and subdomains are shared same source codes written in mvc/c#.
Is it possible for all of the websites/sub domains pointing to one same location of the source codes?
1
I have a layout.cshtml page

I'm trying to get a simple alert('hi'); to fire, but none of the alerts below are firing

 @section scripts{
        <script type="text/javascript">
               alert('hi');
            $(document).ready(function () {

                alert('layout');
               
            });

        </script>
    }

  @RenderBody()


    <!-- PAGE FOOTER -->
    <div class="page-footer">
        <div class="row">
            <div class="col-xs-12 col-sm-6">
                <span class="txt-color-white">@ViewBag.Footer</span>
            </div>

        </div>
    </div>


  @RenderSection("scripts", required: false)

Open in new window



Is there some special order i have to follow to get this working?
0
I am coding super basic paypal  payflow. and  I know every piece of information is correct but I keep getting alert of invalid vendor account.
I did google and I want to confirm that this is not a new  account, and  the account  is in USA so it should not  have any issue. and BIN account is  okay as well.

RESULT >> 26
PNREF >> B90K0C47FE7D
RESPMSG >> Invalid vendor account


ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string paypalRequest = paypalrequestformat(p);

            PayflowNETAPI payflownetapi = new PayflowNETAPI("pilot-payflowpro.paypal.com", 443);           
            string paypalresponse = payflownetapi.SubmitTransaction(paypalRequest, PayflowUtility.RequestId);
            #endregion
            string[] responseItem = paypalresponse.Split('&');
            foreach(string x in responseItem)
            {
                string[] responseItemSplit = x.Split('=');
                Response.Write(responseItemSplit[0] + " >> " + responseItemSplit[1] + "<br>");                
            }

Open in new window

0
0
I have local storage list in Javascript, and I want to make it json format >> using javascript / ajax to send t he json format to mvc controller.
can you show me some samples how to do that?

Thanks
1
What is the best way to update a database table with MVC 5?
I have a select statement which has edit, details and delete options.
If press edit I want to be able to update, but I don't know how to pass the selected row to the edit view.
Here is my code for the select view.

        [HttpGet]
        public ActionResult Select()
        {
            Select C = new Select();
            DataTable dt= C.RetrieveData();
            List<Models.Employee> E = new List<Models.Employee>();
            E = (from DataRow dr in dt.Rows
                         select new Models.Employee()
                         {
                             EmployeeID = int.Parse(dr["EmployeeID"].ToString()),
                             FirstName = dr["FirstName"].ToString(),
                             LastName = dr["LastName"].ToString(),
                             EmpCode = dr["EmpCode"].ToString(),
                             Position = dr["Position"].ToString(),
                             Office = dr["Office"].ToString(),
                             Salary = int.Parse (dr["Salary"].ToString())

                         }).ToList();
            return View(E);
        }
        [HttpPost]//can only be triggered after post from browser
        public ActionResult Select(string FirstName, string LastName,string EmpCode,string Office,string Position,int Salary)
        {
            List<Models.Employee> Employees = new List<Models.Employee>();
            Select C = new 

Open in new window

0
Hi Experts,

I have this query. (I am sorry, I don't know what type of query is this)
var MemberRecentSignIn = _MemberFailedSignInRepository.Get(x => x.UserName == UserName);

Open in new window


This query returns all the records for that user. But I want only the latest record for todays date. I want something like this If I would do in SQL.

SELECT TOP (1) [ID],[UserName],[LockCounter],[LockFlag],[Created]
                                FROM MemberFailedSignIns where 
                                Created >= DATEADD(DAY, 0, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP))
                                AND Created <  DATEADD(DAY, 1, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP))order by created desc

Open in new window

0
ASP.NET webforms has the below events
•      PreInit (IsPostBack and Session available)
•      Init
•      InitComplete
•      PreLoad (ViewState for all controls)
•      Load (Values of controls loaded)
•      LoadComplete (All event handlers raised)
•      PreRender (Last chance to do anything before appearance of form).
•      PreRenderComplete
•      SaveStateComplete (ViewState saved for the page and all controls)
•      Render
•      Unload

What does ASP.NET MVC do?
0
https://checkout.wheelbasepro.com/reserve/68173

Above webpages show 3 months calendars, and I hope to show 12 months on a webpage.
In addition, I have a database to show the event for each month. using MS SQL Server/MVC/c#/razor.

Please let me know what is my option. If using some sort of asp.net/js components to show and list the calendar will be great.

Thanks,
0
I have the following html code

@foreach (var e in ViewBag.Enterprise)
    {

    <li class="configurator-enterprise-li" id="@e.Id">
        <span>@e.Name</span>

        <ul id="site-ul">
            @foreach (var s in ViewBag.Sites)
            {

                <li class="site-li" id="@s.SiteId">@s.SiteName</li>
			}
    ...

Open in new window


This works well with 1 enterprise

But when I add 2 enterprises to the results, it list like this

Ent1
  - site1
  - site2
  - site3
Ent2
  - site1
  - site2
  - site3

instead of
Ent1
  - site2
  - site3
Ent2
  - site1


How do adjust the code so it only shows the correct data

Inside SITE there is a EnterpriseId
i.e. s.EnterpriseId

So I would need a where clause or something similar in razor?
0
0
I have a Asp.net MVC app which sends a float array data to the client

float[320,240]
See attached for the data, its around 1.4mb

I need to dramatically reduce this size, and be able to convert it to the current format in Javascript

Here is the request
 $.ajax({
  type: "POST",
  url: "@Url.Action("CameraChange", "Home")",
  async:true,
  data: "{'cameraId':'" + ID + "'}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (response) {
                 imageTemperatureDataArray = JSON.parse(response.TemperatureDataArray);
  },
   error: function (e) {
       alert("error: " + e.message + ' ');
  }
 });

Open in new window


Then I use it futher down in
 
  $("img#schemesImageSchemes").mousemove(function (e) {
       $('#dataSchemes').text(imageTemperatureDataArray[myX][myY]);
});

Open in new window


Is there a way to reduce this size of the attached
And how would i then convert it in JS ?
floattemparray.txt
0
I'm experimenting with MVC and am writing some code to call a stored procedure that will insert data into a SQL table using a stored procedure.
Why is the Empcode field coming up as null in this controller?  The other fields are fine.

[HttpGet]
        public ActionResult Insert()
        {
            return View();
        }
        [HttpPost]//can only be triggered after post from browser
        public ActionResult Insert(string FirstName, string LastName, string EmployeeCode,string Position,string Office,int Salary)
        {
            //List<Models.Employee> Employees = new List<Models.Employee>();
            //Employees.Add(new Models.Employee { FirstName = "QQQ", LastName = "WWW", EmpCode = "RR", EmployeeID = 90 });
            Models.Employee NewEmployee = new Models.Employee();
            NewEmployee.FirstName = FirstName;
            NewEmployee.LastName = LastName;
            NewEmployee.EmpCode = EmployeeCode;
            NewEmployee.Position = Position;
            NewEmployee.Office = Office;
            NewEmployee.Salary = Salary;
            Insert I = new Insert();
            I.InsertData(FirstName, LastName,EmployeeCode,Position,Office,Salary);
            return View("Insert");

        }

Open in new window


namespace UI.Models
{
    public class Employee
    {
        public int EmployeeID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string EmpCode { get; set; }
        public string Position { get; set; }
        public string Office { get; set; }
        public int Salary { get; set; }
    }
}

Open in new window


Empcode is 3rd textbox in the following view.


Open in new window

0
we use datatable and one column is a list of checboxes or buttons. and we have some on click event to do something.

what I try to achieve is when the user scroll down to view and on click. then after the event is done. the page is reloaded back to the top of the page

how can I keep the scroll position in this case.?
0
I need to send a simple javascript / jQuery alert message from my controller in MVC5. How do I do this? I have the code below in place, but the alert is not firing, nothing happens when the line of code with the script in it is hit.

				if (manager.AddedServicesList == null)
				{
					Response.Write("<script>alert('NO SERVICES ADDED');</script>");
					return RedirectToAction("Category", manager);
				}
				else
					return RedirectToAction("GroupDetails", manager);

Open in new window


This works, but then I just get a blank page. I need to get back to/stay on/in the view where I'm currently at.

return Content("<script language='javascript' type='text/javascript'>alert('Hello world!');</script>");

Open in new window

0

.NET MVC

399

Solutions

298

Contributors

Microsoft’s ASP.NET MVC is a web application framework that implements the model–view–controller (MVC) pattern. As an open-source software, it’s set apart from the ASP.NET Web Forms component, which is proprietary.

Top Experts In
.NET MVC
<
Monthly
>