简体   繁体   English

如何使用asp.net作为服务器端语言在服务器上存储json文件以及如何使用javascript,html和css访问json数据?

[英]how to store json file at server using asp.net as server side language and how to access json data using javascript, html and css?

I am a newbie in web development. 我是网络开发的新手。 I am in the process of building a food blog website. 我正在建立一个美食博客网站。 I want to pursue front-end-web-developer career. 我想追求前端网络开发人员的职业生涯。 I have built my website only using client side languages like javascript, jquery, html and css. 我只使用javascript,jquery,html和css等客户端语言构建了我的网站。 I have used json to store the data. 我用json来存储数据。 my questions are - 我的问题是 -

1. I now want to make my website live. 我现在想让我的网站上线。 For that I want my website to be hosted on server. 为此,我希望我的网站托管在服务器上。 As I am not using any server side scripting, would my data related to website be visible to everyone if they do try to "inspect element" or "view source"? 由于我没有使用任何服务器端脚本,如果他们确实尝试“检查元素”或“查看源代码”,我的每个人都可以看到与网站相关的数据吗?

2. how can I separate Json from client side code/scripting? 2.如何将Json与客户端代码/脚本分开? I think for that I will have to seperate json data from other javascript code and store it into a separate file on a server. 我认为,我将不得不从其他javascript代码中分离json数据并将其存储在服务器上的单独文件中。 But in that case how can I access the Json data? 但在这种情况下,我如何访问Json数据? For that I will have to make use of some server side scripting language. 为此,我将不得不使用一些服务器端脚本语言。 I prefer Asp.net(not that I know asp.net but I am familiar with C# hence). 我更喜欢Asp.net(不是我认识asp.net,但我熟悉C#)。 I also would have to make changes to my html code at client side to fetch the Json data from server. 我还必须在客户端更改我的html代码以从服务器获取Json数据。 I am not really aware of this whole thing. 我并不是真的意识到这一切。 Could someone spare some time and let me know how to go about it? 有人可以节省一些时间让我知道如何去做吗?

3. Does all the client side and server side code lies in a single asp.net project? 3.所有客户端和服务器端代码都在一个asp.net项目中吗?

I have searched over internet. 我在网上搜索过。 Mostly all the material/coding available over internet is mostly in php or python hence I am confused. 通常互联网上的所有材料/编码大部分是在php或python中,因此我很困惑。 There no definite guideline that I could find as how to handle the data part only using JSON? 没有明确的指导我可以找到如何只使用JSON处理数据部分?

to help you answer your 2nd question 2. how can I separate Json from client side code/scripting? 帮助您回答第二个问题2.如何将Json与客户端代码/脚本分开? usually server side is in the controller so your HomeController.cs for instance will have an Index action (public ActionResult Index()) that method will basically be called whenever the browser hits the route Home/Index.cshtml in order to separate these two, you may fetch or construct your Json in the controller and pass it to the ViewBag, from there you can access it in the view. 通常服务器端在控制器中,所以你的HomeController.cs会有一个Index动作(公共ActionResult Index()),只要浏览器到达Home / Index.cshtml路由以便将这两个分开,基本上就会调用该方法,您可以在控制器中获取或构建Json并将其传递给ViewBag,然后您可以在视图中访问它。 using $.ajax will help as well to get the json from the view and update the content of a specific part of your page for instance. 使用$ .ajax也可以帮助从视图中获取json并更新页面特定部分的内容。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在HTML模板(ASP.NET)中显示使用JavaScript饼图中的AJAX方法从客户端检索的动态服务器端数据 - How to display dynamic server side data retrieved from client side using AJAX method in a Javascript Pie Chart, in a html template (ASP.NET) 如何在不使用服务器端语言的情况下从 HTML 表单存储/发送数据? - How do I store/send data from a HTML form without using a server side language? 如何在ASP.Net中使用jQuery调用服务器端函数 - How to call server side function using jQuery in ASP.Net 如何从服务器获取JSON文件? (ASP.NET) - How to get JSON file from server? (ASP.NET) 如何使用c#将服务器端处理的数据从代码隐藏添加到asp.net中.aspx页面中的javascript - How to add server-side processed data from code-behind to javascript in .aspx page in asp.net using c# 如何使用javascript设置asp.net的label文本并在服务器端获取设置值 - How to set asp.net 's label 's text using javascript and get setted value on server side 如何创建动态生成的按钮,以在ASP.Net C#中使用javascript调用服务器端方法 - how to create dynamicly generated button that call server side method in using javascript in ASP.Net c# 如何使用JavaScript / PHP将变量数据导出到服务器上的JSON文件? - How to export variable data to a JSON file on the server using JavaScript/PHP? 使用javascript从服务器端asp.net引导警报 - bootstrap alert from server side asp.net using javascript 使用JavaScript在ASP.NET中的列表框之间移动项目的最佳方法,然后在服务器端访问结果 - best way to move items between ListBoxes in ASP.NET using javascript, then access results on server side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM