Subscribe: ASP.NET AJAX Discussion and Suggestions
http://forums.asp.net/rss.aspx?ForumID=1007&PostID=1446560
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
add  code  date  error  facebook  net  new  public  return  runtime  server  set  system runtime  system  task  token 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: ASP.NET AJAX Discussion and Suggestions

All Forums



All Forums



Last Build Date: Thu, 19 Apr 2018 09:05:33 -0700

 



In the mvc using the razor, how do you call and actionresult function with date time parameters?

2018-04-17T20:21:19.57-07:00

Hi All,

I can;t get the cshtml file to pass a date value to the controller function. I am just trying to test before I make textbox fields

for the date just to make sure the function works. So I am just trying to make it so that it runs that a hard coded date value.

So I have this code in the cshtml file

@{
    ViewBag.Title = "CostCodeeReport";

    var SD = DateTime.Parse("01/01/2018");
    var ED = DateTime.Parse("02/01/2018");
}

AVRIS Cost Code Page

@Html.ActionLink("Run Cost Code Report", "CostCodeReport", new { StartDate = SD, EndDate = ED})

In the mvc controller this is the actionresult function

        [HttpPost]
        [ValidateAntiForgeryToken]

        //ModelBinger Infomation here :https://weblogs.asp.net/scottgu/asp-net-mvc-preview-5-and-form-posting-scenarios
        [HandleError]

        public ActionResult CostCodeReport(DateTime StartDate, DateTime EndDate)
        {


            DateTime ST_Date = Convert.ToDateTime(StartDate);
            DateTime ED_Date = Convert.ToDateTime(EndDate);

            var ReportData = from r in db.VUE_COSTCODE_REPORT where r.START_DATE >= ST_Date && r.END_DATE <= ED_Date select r;


            ////Get Report Data
            try
            {
                var DT_ReportData = ReportingTools.ToDataTable(ReportData);
                var Byte_ReportData = ReportingTools.csvBytesWriter(ref DT_ReportData);
                ReportingTools.SaveFileCVS(Byte_ReportData, "CostCodeReport");

When I step into the source it never reaches the function in the controller... I have it under the httpPost option. Is that correct? Any thoughts?




Calculate the sum of all subtotals for each item (Simple shopping cart)

2018-04-19T14:33:04.137-07:00

Hello,

I have managed to display the items in the view as below except the total.  How can I calculate the sum of all the subtotals based on the tables that I have and the code I have written? Can someone help me, please?

(image)

Here is my code: 

public class CartViewModel
{
    public Guid ProductId { get; set; }

    public string Name { get; set; }

    public decimal Price { get; set; }

   public int Quantity { get; set; }

   public decimal Subtotal { get; set; }
}
// Controller

Guid userId = Guid.Parse(User.Identity.GetUserId());
// Joining 3 tables based on their references for the current user 
var userProducts = from cart in db.Carts join cartProduct in db.CartProducts on cart.Id equals cartProduct.CartId join product in db.Products on cartProduct.ProductId equals product.ProductId where cart.UserId.Equals(userId) select new CartViewModel { ProductId = product.ProductId, Name = product.Name, Price = product.Price, Quantity = cartProduct.Quantity, Subtotal = (product.Price * cartProduct.Quantity), };
return View(userProducts);


(image) (image) (image)

Thank you! (image)




REST WEBSERVICE

2018-04-19T15:48:20.84-07:00

I've a website in ASP.NET 3.5 (VB). I need to build a REST webservice. Goal is put some information to my website and return TRUE or FALSE. Because I've not experience with REST searching on web found only asp.net API solution. There is a way to do this with asp.net 3.5?

Can someone send me an example?




enable SSL for a .NET project in Visual Studio

2018-04-19T12:03:57.18-07:00

this way i enable SSL for a .NET project in Visual Studio2013. screen shot

(image)

(image)

decorate home controller with  [RequireHttps] like

    [RequireHttps]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        [Authorize]
        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}

everything working fine but when i use http instead of https in browser address bar then no page content comes.....why?

at least asp.net engine throw error to say use https instead of http.




JQuery syntax signalR Call

2018-04-18T13:57:54.523-07:00

Hi,   On an MVC application I want to lock records that are being edited. (see also my previous question ) I realize now that I need to keep a list of Locked records on the server for this. I am doing this in memory since only a few users will be working with the application at the same time. So this is my Lock list: public class  LockList     {         static List _LockList;           static LockList()         {             _LockList = new List();         }                   public static void Add(long id, string psn)         {             Lock l = _LockList.SingleOrDefault(x => x.Id == id);             if(l==null)             {                 Lock lo = new Lock();                 lo.Id = id;                 lo.Set = DateTime.Now.ToString();                 lo.By = psn;                 _LockList.Add(lo);             }                     }           public static void Remove(long id)         {             Lock l = _LockList.SingleOrDefault(x => x.Id == id);             if (l != null) _LockList.Remove(l);         }           public static bool Contains(long id)         {             Lock l = _LockList.SingleOrDefault(x => x.Id == id);             return l != null;         }           public static List GetLockList()         {             return _LockList;         }             public class Lock         {             public long Id { get; set; } //The Id of the locked record             public string  Set { get; set; } //The date and time of the lock             public string By { get; set; } // the userId         }     }   And this is my hub:   public class HandOverHub : Hub     {         public void NotifyLock(long Id)         {             Debug.WriteLine("Locking " + Id);             LockList.Add(Id,"");       &nbs[...]



Countdown Timer/ Pass remaining time value from view to controller

2018-04-18T16:22:18.303-07:00

Greetings,

I wanna create a countdown timer in the view that starts from,let's say 3minutes, and when i click on a submit button in the view the value of the remaining time in that timer will be sent to the controller where i can affect it to my model ,let's say i have a model called "Exam", then Exam.RemainingTime will receive the value of the remaining timer in the view and i'll be able to save it in the database.

Thank you.




Send out an email to more than 500 recipients

2018-04-19T12:55:41.977-07:00

I used code below to send out an email to more than 500 recipients using a loop.
"mailto" is the recipients from a table in which there are more than 500 recipients.
But got an error said that

System.Net.Mail.SmtpException: Service not available, closing transmission channel. The server response was: 4.3.2 The maximum number of concurrent connections has exceeded a limit, closing transmission channel

IT people already increased The maximum number of concurrent connections from 1000 to 5000 in Exchange.
How to fix it?

Dim mail As New MailMessage()
mail.From = New MailAddress("company@company.com")
mail.To.Add(mailto)
mail.Subject = "Order detail"
Dim strBody As String="This is a test"
Dim myMail As New SmtpClient("email.company.com")
myMail.Credentials = New System.Net.NetworkCredential("company", "password")
myMail.Send(mail)
myMail.Dispose()




Cannot insert duplicate key row in object 'dbo.TableName' with unique index

2018-04-19T01:14:49.21-07:00

CREATE UNIQUE CLUSTERED INDEX [IX_Daily_Checks_01] ON [dbo].[TableName] ( [CheckDate] ASC, [ServerName] ASC, [DBName] ASC, [CheckType] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)

insert into TableName select Date, ServerName, DBName, DBNum, CheckType, Message from Master.dbo.ChildTableName where Date between dateadd(hour, 12, (Convert(DateTime, DateDiff(day, 0, getdate() - 1)))) and dateadd(hour, 8, (Convert(DateTime, DateDiff(day, 0, GetDate()))))

Error connecting to server ServerName. Exception calling "WriteToServer" with "1" argument(s): "Cannot insert duplicate key row in object 'dbo.TableName' with unique index 'IX_Daily_Checks_01'. The duplicate key value is (2018-04-18 18:35:34.7200000, ServerName, , Backup AG).

Any inputs on resolving above issue with out changing index functionality?




Facebook auth redirect url

2018-04-19T13:12:21.6-07:00

see the picture please

(image)

i have few questions for auth redirect url 

1) why this auth redirect url would be required ?

2) if my site has no url called /signin-facebook then what will happen ?

3) how to get and show facebook logged in user name at top right instead of email address?

please guide me for the above points.




Unable to increase the width of html drop-downs which are in Juqery data table

2018-04-19T14:32:41.353-07:00

Dear All,

I have drop-downs in my Jquery Data table and I tried the below css , But I found no luck.

Can any one suggest me how what's wrong .

select#txtparticipateidvalue{width:280%;
}
.txtparticipateidvalue select
{width:60px !important;
}


 




How to set selected value from database for Html.DropDownList on pageload?

2018-04-19T14:27:05.603-07:00

I am populating a dropdownlist on an edit page from another table called UserAccounts in my database. Once the user is selected from this dropdownlist the selected value gets set as the owner field in the Todo table in my database. I have it so that this is working. The thing is when I click the edit page of a specific todo item, even when the owner of the todo is not null, the value of the dropdownlist gets set to "Select" because that is the default value of it. How do I code it so that if the Owner field is null, have it set to "Select" but if there is an owner in the field, I want the dropdownlist to be preselected as that owner? Controller: public ActionResult Edit(int? id, string owner) { if (Session["UserId"] != null) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Todo todo = db.Todoes.Find(id); if (todo == null) { return HttpNotFound(); } var options = new List(); options.Add(new Todo() { Status = "New Request", Text = "New Request" }); options.Add(new Todo() { Status = "Reviewed", Text = "Reviewed" }); options.Add(new Todo() { Status = "Started", Text = "Started" }); options.Add(new Todo() { Status = "In Progress", Text = "In Progress" }); options.Add(new Todo() { Status = "Completed", Text = "Completed" }); ViewBag.Status = options; List osrListItems = db.UserAccounts.Where(w => w.OSR != null).Select(osr => new SelectListItem { Value = osr.OSR, Text = osr.OSR }).Distinct().ToList(); ViewBag.OSRddl = new SelectList(osrListItems, "Value", "Text").Distinct(); //string x = ViewBag.OSRddl.Value; //if (todo.Owner != null) //{ //} return View(todo); } else { return RedirectToAction("Login", "Account"); } } // POST: Todoes/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edit([Bind(Include = "ID,Description,CreatedDate,Task,Status,FollowUp,Group,Owner")] string OSRddl, Todo todo) { if (Session["UserId"] != null) { //document.getElementById('FollowUp').value= if (ModelState.IsValid) { if (OSRddl != null) { todo.Owner = OSRddl; } db.Entry(todo).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(todo); } else { return RedirectToAction("Login", "Account"); } } View:
@*

Todo

*@
@Html.ValidationSummary(true, "", new { @class = "text-danger" }) @Html.HiddenFor(model => model.ID) @if ("OSRddl" !=[...]



HTTP Error 500.21 - Internal Server Error .NET WCF service

2018-04-19T13:59:00.11-07:00

I uploaded a wcf service to a web hosting and it was working fine, I could access to it, but suddenly it started throwing this error when I try to open it IIS 8.5 Detailed Error HTTP Error 500.21 - Internal Server Error Handler "svc-Integrated" has a bad module "ManagedPipelineHandler" in its module list I've been searching and for what I understand it has something to do with the requisites for ASP.NET, it was suggested to run this command: aspnet_regiis.exe -i But since I'm using a shared hosting it's not much of an option, I don't know if I can add a handler to my web config or if I have to contact my provider to solve it. The strange thing for me is that I was working with it without problems for months and it just suddenly threw that error. Here's my webconfig:
>



Class Library with Entity Framework Core

2018-04-19T08:24:37.537-07:00

Hi,

Someone know where I can find any guide about how develop a Class Library Project with Entity Framework Core for .NET Core 2.0 or higger?

The problem is that when we develop an asp.net core mvc application, we add the context to the IServiceCollection on the ConfigureServices method. But on a Class Library Proyect we does not have a Startup.cs class to configure it, and so I don't know how approach that.

On a MVC application, Microsoft guides us to make that as following code, but, How can we make it on a Class Library without that class (startup.cs)?

public void ConfigureServices(IServiceCollection services)
{
      services.AddDbContext(options =>options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
}

Thanks a lot,

Regards!!!




some words related to token authentication

2018-04-18T11:10:53.577-07:00

i always works with form auth and still never use token auth. so today i browse few articles on token auth then i came to few Terms like Bearer Token, access and refresh token, jwt, oauth.

those above terms are not clear to me. so i have few question. if anyone knows then please answer details for my each points.

1) How many type of token exist ?
2) what is bearer token?
3) what is access token
4) how access token is different from bearer token
5) gime me sample bearer token format just to know what kind of info is there in bearer token.

6) difference between access token and refresh token
7) how jwt is different from bearer token?

8) what is difference between basic auth and token auth?
9) in case of basic auth server generate and send any token to client
10) normally when we do token auth with web api v2 then webapi generate bearer token or jwt?

i know i have asked 10 questions if possible please answer me point wise in details.

thanks




EF How AddOrUpdate identify which is PK

2018-04-19T11:56:17.46-07:00

when AddOrUpdate update data in table then how it understand which field is PK in table or unique row identifier because when we update then we write query like

update tablename set col='',col1='' where rowidentifier=value

public async  Edit(Customer customer)  
{  
    context.AddOrUpdate(customer)  
    context.SaveChangesAsync();  
    return RedirectToAction(nameof(Index));  
}  




Problem in generating pdf after shifting the website on Cloud

2018-04-19T11:17:23.017-07:00

We generate pdf certificates for our users through itextsharp namespace in the dot net 3.5 application platform which we are using. Now after we have shifted our website to cloud (earlier it was on shared hosting) the website is not generating the pdf. Although it is working on our localhost on our Windows 8 computer and was also working on the earlier shared hosting server.

Only after we have shifted to Cloud on (Application Server OS - Windows Server 2012, Database Server OS - Windows Server 2012 R2) that is has stopped generating pdf and we are unable to click or download the pdf icon.

Help from experts is urgently requested for this issue.




Entity Framework Core Invalid Column after updating database table

2018-04-18T20:08:28.41-07:00

I am using code first from the database using Asp.net core. I have a table: UserRoles where I need to remove a CategoryId column and add in the OrganizationId reference. Everything works, but when I go to delete (in order) my organizations, I try to delete from UserRoles first.  Well for some reason I am seeing the error below. Any ideas? System.Data.SqlClient.SqlException (0x80131904): Invalid column name 'CategoriesCategoryId'. at System.Data.SqlClient.SqlCommand.<>c.b__174_0(Task`1 result) at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.d__17.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.d__7`2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator`2.d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Linq.AsyncEnumerable.AsyncIterator`1.d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Here is my code to set my connection string. Now in my local SQL db, I do have multiple databases for initial categlog. Other tables DO have that column still because I haven't updated those databses. Could the appsetting json file be pulling another dat[...]



ThermalLabel SDK 8.0 released! 4X Faster plus ASP.NET CORE Support

2018-04-19T12:03:55.71-07:00

We're very excited to announce v8.0 of our ThermalLabel SDK for .NET with lots of new features! ThermalLabel SDK for .NET Standard Library lets you to create advanced barcode labels and print them to Zebra ZPL/EPL-compatible & Honeywell-Intermec Fingerprint Thermal Printers by writing just pure .NET code in VB.NET or C#. We also offer ThermalLabel Visual Editor Add-on, a first-class customizable barcode label designer component for ASP.NET projects based on HTML5/JS!

More info about ThermalLabel SDK 8.0

This Version 8.0 is 4X Faster than previous versions and brings support for .NET CORE, Xamarin, Mono & UWP!

Learn more about the new features at What's New in v8.0!

DOWNLOAD fully functional eval version!




Getting MAC Address of a Client's PC

2018-04-18T12:35:29.623-07:00

I have been trying whole day to get the MAC Address of the client PC. I have tried 2 ways to do so:

1) Using NetworkInterface: But it tries to retrieve the MAC address of server ( i.e where my website is hosted ) and returns error as server is not allowing it to access its MAC and I also dont need it.

2) Using ManagementObjectSearcher: while doing this I added reference of ManagementObject on my local machine and tested it, it worked completely fine. But when I uploaded it to Server its asking for the reference to be added first. For that i copied all the management files from my App_Code folder to the App_code folder on my server, But still the error remained same.

Suggestions required on:

1) Is there any 3rd way of getting the MAC Address of the Clients PC (The one who browses the website at his home).
2) How can I add that ManagementObject reference to my server.

I'll be very thankful to one who gets me through this.




Facebook authentication throwing error you are not logged in

2018-04-18T13:00:22.657-07:00

i read a article which showed few steps we need to perform to get appid and src from fb and i got also appid and src which i put like

public void ConfigureAuth(IAppBuilder app)
{
....

app.UseFacebookAuthentication(
appId: "xxxxxxxxxxx",
appSecret: "xxxxxxxx");
}
when i go to login page there i found a button called facebook and i click there which redirect to me to facebook with a error.

my facebook redirected url looked like https://www.facebook.com/dialog/oauth?response_type=code&client_id=3333333333333&redirect_uri=http%3A%2F%2Flocalhost%3A53540%2Fsignin-facebook&scope=&state=H2lomfBAWcy4c6Lq3kO0qAs6GGaddFhEnaDEhvGzoq4DSOi8HU2xQy9ONj9XDvpZFk-LNSqsn6oDgG-6uDIfeZYmLuApvluxnDmhze1_9r1YbgCC02bFhj9xc6wuHGPPlckbu1tfTQuBYvgA1Tf7kgqujoAUc7OKQLDoWZ6Akg3ZDhXSaGCxi6tMgh4EnDRlf9Qcb3Y1FvEmps4J7ELiSu8pCevfURuUarzg5kdfY6A

and the error message show on facebook page look like....screen shot attached

(image)

see the error message and as if error trying to say we need to sign in to facebook in advance before clicking on facebook button on my site.

i configure my site for https. i follow these two article for facebook auth integration in asp.net mvc 5. those article's urls are

https://docs.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on#creating-the-app-in-facebook-and-connecting-the-app-to-the-project
https://www.c-sharpcorner.com/article/authentication-using-facebook-in-asp-net-core-2-0/

please tell me what i mistake for which i am getting this error.

also another question is how redirect url is generated by asp.net mvc because the same url i did not find in whole project code?

where this code is written https://www.facebook.com/dialog/oauth?response_type=code&client_id=3333333333333&redirect_uri=http%3A%2F%2Flocalhost%3A53540%2Fsignin-
thanks