[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How secure is database code in a Razor file?

Posted on 2011-10-17
2
Medium Priority
?
315 Views
Last Modified: 2012-05-12
I have never used Razor to hold database code, and probably never would. But given that the C# resides on the server, is this a safe way to protect from the database code being visible to the user?

Curious...


@{
var db = Database.Open("SmallBakery"); 
var selectQueryString = "SELECT * FROM Product ORDER BY Name"; 
}
<html> 
<body> 
<h1>Small Bakery Products</h1> 
<table> 
<tr>
<th>Id</th> 
<th>Product</th> 
<th>Description</th> 
<th>Price</th> 
</tr>
@foreach(var row in db.Query(selectQueryString))
{
<tr> 
<td>@row.Id</td> 
<td>@row.Name</td> 
<td>@row.Description</td> 
<td aligh="right">@row.Price</td> 
</tr> 
}
</table> 
</body> 
</html>

Open in new window

0
Comment
Question by:newbieweb
2 Comments
 
LVL 39

Accepted Solution

by:
Aaron Tomosky earned 2000 total points
ID: 36983571
Open your page in a browser and you will see everything a user can see. And CSS and included js files are also seen client side. Anything in your aspx is safely server side. Make sure directory browsing is off and your default website is off. There are also more advanced steps to keep stuff safe but the short version is that anything serverside is safe.
0
 

Author Closing Comment

by:newbieweb
ID: 36989556
Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question