|
HI,
i want to return token if user is valid but i do not want to use identity to generate token. so please guide me how to achieve it or redirect me to any relevant article which show me how to generate token without identity or membership etc.
thanks
|
|
|
|
|
Are you authenticating completely out of band with ASP.NET? I'm trying to figure out how you would apply privileges in that scenario, and failing.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
i asked this question out of my curiosity. i like to know is it possible or is it mandatory that some one need to use identity because i am working with old version of asp.net mvc project then how can i generate token where identity does not exist.
thanks
|
|
|
|
|
The .NET ecosystem comprises of 3 major high-level components, namely .NET Framework, .NET Core, and Xamarin.
The .NET Framework is used to create Windows applications using WPF and Windows Forms and Web applications making use of ASP.NET MVC.
How .NET Core fits in the .NET Ecosystem?
|
|
|
|
|
pls send add to cart code in asp.net using sql server
|
|
|
|
|
No. If you want some code written then you need to write it. Alternatively you could use Google or Bing and do some searching for yourself.
|
|
|
|
|
Gladly. Send your credit card information first though.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
By the way, who is Ashraf and why did you call their name?
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I have developed a tabular UI with webgrid. i am showing student information through webgrid. i am showing multiple checkboxes for hobbies in each row of webgrid. when i select hobbies and click submit button then i saw hobbies selection is not going to action.
i guess there is my mistake in view model class design. please have a look at my code and tell me which area i need to change in code.
i want all hobbies should go to action when i click submit button and selected hobbies also should post to action for each student. a student may have multiple hobbies selected.
here is my viewcode
@model MVCCRUDPageList.Models.StudentListViewModel
@{
ViewBag.Title = "Index";
}
<h2>Student View Model</h2>
@using (Html.BeginForm("Index", "WebGridMoreControls", FormMethod.Post))
{
var grid = new WebGrid(Model.Students, canSort: false, canPage: false);
var rowNum = 0;
var SelectedHobbies = 0;
<div id="gridContent" style=" padding:20px; ">
@grid.GetHtml(
tableStyle: "table",
alternatingRowStyle: "alternate",
selectedRowStyle: "selected",
headerStyle: "header",
columns: grid.Columns
(
grid.Column(null, header: "Row No", format: item => rowNum = rowNum + 1),
grid.Column("ID", format: (item) => @Html.TextBoxFor(m => m.Students[rowNum - 1].ID, new { @class = "edit-mode" })),
grid.Column("Name", format: (item) => @Html.TextBoxFor(m => m.Students[rowNum - 1].Name, new { @class = "edit-mode" })),
grid.Column("Country", format: (item) =>
@Html.DropDownListFor(x => x.Students[rowNum - 1].CountryID,
new SelectList(Model.Country, "ID", "Name", item.CountryID),
"-- Select Countries--", new { id = "cboCountry", @class = "edit-mode" })),
grid.Column(header: "Hobbies",
format: @<text>
Hobbies
@foreach (var hobby in Model.Hobbies)
{
<div class="checkbox">
<label>
@Html.HiddenFor(e => e.Hobbies)
<input type="checkbox"
name="Hobbies"
value="@hobby.ID" /> @hobby.Name
</label>
</div>
}
</text>)
))
<input type="submit" value="Submit" />
</div>
}
Action code
public class WebGridMoreControlsController : Controller
{
// GET: WebGridMoreControls
public ActionResult Index()
{
StudentListViewModel osvm = new StudentListViewModel();
return View(osvm);
}
[HttpPost]
public ActionResult Index(StudentListViewModel oStudentListViewModel)
{
return View(oStudentListViewModel);
}
}
View model code
public class StudentListViewModel
{
public IList<Student> Students { get; set; }
public List<Country> Country { get; set; }
public IList<Hobby> SelectedHobbies { get; set; }
public IList<Hobby> Hobbies { get; set; }
public StudentListViewModel()
{
Students = new List<Student>
{
new Student{ID=1,Name="Keith",CountryID=0,Hobby=0},
new Student{ID=2,Name="Paul",CountryID=2,Hobby=0},
new Student{ID=3,Name="Sam",CountryID=3,Hobby=0}
};
Country = new List<Country>
{
new Country{ID=1,Name="India"},
new Country{ID=2,Name="UK"},
new Country{ID=3,Name="USA"}
};
Hobbies = new List<Hobby>
{
new Hobby{ID=1,Name="Football"},
new Hobby{ID=2,Name="Hocky"},
new Hobby{ID=3,Name="Cricket"}
};
}
}
Model code
<pre lang="c#"> public class Student
{
public int ID { get; set; }
[Required(ErrorMessage = "First Name Required")]
public string Name { get; set; }
public int CountryID { get; set; }
public int Hobby { get; set; }
}
public class Country
{
public int ID { get; set; }
public string Name { get; set; }
}
public class Hobby
{
public int ID { get; set; }
public string Name { get; set; }
}
please help me to rectify view, viewmodel and model class code. thanks
|
|
|
|
|
Here is how i read the json file.
[System.Web.Services.WebMethod]
public static string read()
{
object obj = JsonConvert.DeserializeObject<string>(File.ReadAllText(@"C:\Users\User\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\test\dataTbl.json"));
return obj.ToString();
}
but i getting an error: Error reading string. Unexpected token: StartArray. Path '', line 1, position 1.
Anyone can help?
modified 27-Feb-18 2:48am.
|
|
|
|
|
I think your JSON data needs to start and end with curly braces, not square brackets. So it should be something like:
{
[
{
"name": "chris",
"ic": "111111-11-1111",
"phone": "011-1111111",
"address": "street 01",
"gender": "male"
},
{
"name": "carolyn",
"ic": "222222-22-2222",
"phone": "012-2222222",
"address": "street 02",
"gender": "female"
}
]
}
And you may also need a label in front of the main array to identify it.
|
|
|
|
|
If you look at the documentation[^], or google for any example on-line, you'll see the type you supply DeserializeObject is the type you want the json to be converted to. You are saying you want the json converted to a string which makes no sense as it is already a string. So you're confusing the json parser.
Again referring to the documentation you need to create a class that represents your data and deserialise to that. So create a class like
public class Person
{
public string name { get; set; }
public string ic { get; set; }
public string address { get; set; }
public string gender { get; set; }
}
as your json is an array of these objects you was to convert it to a List<Person>
List<Person> obj = JsonConvert.DeserializeObject<List<Person>>( ... );
|
|
|
|
|
i want to update a local json file (add & remove) at server side, can anyone show me how to do it?
I pass a id parameter to determine which record i want to remove from client side to server side using ajax
$.ajax({
type: "POST",
url: "WebForm1.aspx/remove",
data: "{id:" + id+ "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
after that i had no idea how to code to modify the local file.
[System.Web.Services.WebMethod]
public static void remove(string id)
{
}
|
|
|
|
|
You can't modify files on the client from your server code.
|
|
|
|
|
How to prevent "OnSelectedIndexChanged" event triggered in DropDownCheckBoxes. When DropDownCheckBoxes Bound using asp.net?
|
|
|
|
|
How to enable Searchable dropdowncheckboxes (like AutoFilter) in asp.net
|
|
|
|
|
How to Filter the data in GridView using Linq Query without going to DataBase in VB.NET
|
|
|
|
|
|
i am not sure that always browser cache pages we visited. so my question is when browser cache web site pages? whatever site we visit browser cache each pages ?
if yes then how long browser cache each pages ?
how browser check website pages changes compared with client side cache pages ?
please help me with knowledge. thanks
|
|
|
|
|
people often load js file from CDN. what is advantage?
people said js file is cached there in CDN so load faster. so what can i do to cache js file where my site is deployed?
thanks
|
|
|
|
|
Pls Provide me business logic method for reset password or forget password by user id...
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to Freelancer.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
So either pay someone to do it, or learn how to write it yourself. We aren't here to do it for you.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
ohh sorry for that by the way can you provide me idea how can we implement method for that... if possible otherwise its ok! 😊
|
|
|
|
|

in order to reset password you have to give email link or else you can give direct web page link. before reset password. you should take email address from the user. so you can use in where clause. see my code:
protected void save_Click(object sender, EventArgs e)
{
if (password.Text != "" || confirmpassword.Text != "")
{
if (password.Text == confirmpassword.Text)
{
con.Open();
SqlCommand cmd = new SqlCommand("update login set password='" + password.Text + "', confirmpassword='" + confirmpassword.Text + "' where email='" + Session["email"] + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "Password Reset Successfully";
HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "Refresh";
meta.Content = "5;url=loginuser.aspx";
this.Page.Controls.Add(meta);
}
else
Label1.Text = "Password not Matched";
}
else
Label1.Text="Please Enter Password";
}
ask email or username. then display password reset webpage. use email or username in where clause to update password.
if you want id then use sql query like
select id from userDetails where email=session["email"];
i hope you will understand.
|
|
|
|
|
thanks, Ya I understood... you have well explained!😊
|
|
|
|