|
MVC is still asp.net and you authenticate users the same way you would in an asp.net web application. There is a multitude of sources covering asp.net authentication, you should have no problem finding information if you look.
With MVC you can also use the authorize attribute on your controller methods, and again, there are multiple sources if you look, like here http://nerddinnerbook.s3.amazonaws.com/Part9.htm[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You have misunderstood my comments. I want to grant permissions for users and gives them the right to impose different. for example, the administrator will have the right to edit and manage the website, the user may only read information, change their profile and of course can not change anything in the website.
the example you give I got it but I want to add permissions for each different member.
|
|
|
|
|
You have misunderstood my answer. That is the way to handle authentication and authorization. I think you need to read more carefully, look for this; "A better approach is to define higher-level "roles" that the code checks against", that should give you a hint.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Dear all
I need a Text box Auto Complete Exact like www.justdial.com using asp.net and jQuery
Every Suggestion and Help are Highly appreciated
Thank You
modified on Saturday, May 28, 2011 2:40 AM
|
|
|
|
|
|
Luckily, I was working on this very problem today:
<html>
<head>
<title>jQuery Auto-Complete Using Google Maps API</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
$(document).ready(function () {
function AutoCompleteSample() {
}
AutoCompleteSample.handleAutocompleteRequest = function (request, response) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: request.term}, function(results, status) {
response($.map(results, function(item) {
return {
label: item.formatted_address,
value: item.formatted_address,
latitude: item.geometry.location.lat(),
longitude: item.geometry.location.lng()
};
}));
});
};
AutoCompleteSample.create_handleFoundLocation = function () {
return function (event, ui) {
var lat = ui.item.latitude;
var lon = ui.item.longitude;
var location = new google.maps.LatLng(lat, lon);
alert(location);
};
};
$("#txtAddress").autocomplete({
source: AutoCompleteSample.handleAutocompleteRequest,
select: AutoCompleteSample.create_handleFoundLocation()
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
<input type="text" id="txtAddress" />
</body>
</html>
That JavaScript is highlighted strangely in the above PRE block, so here is the JavaScript by itself (i.e., without the HTML):
$(document).ready(function () {
function AutoCompleteSample() {
}
AutoCompleteSample.handleAutocompleteRequest = function (request, response) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({address: request.term}, function(results, status) {
response($.map(results, function(item) {
return {
label: item.formatted_address,
value: item.formatted_address,
latitude: item.geometry.location.lat(),
longitude: item.geometry.location.lng()
};
}));
});
};
AutoCompleteSample.create_handleFoundLocation = function () {
return function (event, ui) {
var lat = ui.item.latitude;
var lon = ui.item.longitude;
var location = new google.maps.LatLng(lat, lon);
alert(location);
};
};
$("#txtAddress").autocomplete({
source: AutoCompleteSample.handleAutocompleteRequest,
select: AutoCompleteSample.create_handleFoundLocation()
});
});
Here is some documentation:
|
|
|
|
|
I have a two forms i.e Form1 and Form2.When I submiting Form1 it will redirect to Form2.But Form2 was taking time while loading
So I want while loading Form2 one page will display.So after Form2 loads that page will not display.
Kindly check the site of cleartrip.com and search for flights.While searching flights one page is displaying and after that
the flight details page will display...
I want to show the waiting page... while in background actual page is loading....
How can I do this in ASP.NET...?
Please help me on this...
|
|
|
|
|
|
actually I have an html page on which progress bar is there... I want to display that html page while loading the second page(i.e Form2)... Kindly check site cleartrip.com... and click on search flights... In that after clicking on search flights on page is displayed... like loading... and after that flight details page is displayed ... I want to display like that...
|
|
|
|
|
Ah, so I don't think you actually want to display an intermediate page while the desination page is loading (e.g., loading JavaScript files, CSS files, and so on). My guess is you are doing some sort of database query that makes the desination page take a long time to load. In that case, when you nagivate to the intermediate page, do the database queries there. Once the database queries have completed, stored them in a temporary table or a session variable to cache them, then redirect the user to the destination page (which will then load the data from the cache).
Also, that would basically be the same as showing a splash screen on your destination page while the page loads. That's the route I recommend you take. You basically show an image (or progress bar or whatever) and when your page has finished loading, you hide the splash screen (which reveals your actual page).
|
|
|
|
|
actually requirement is to display html page only.... not the image...
Please help me .... how can I do that in ASP.NET....?
|
|
|
|
|
I just told you, but you seem to just be focusing on that last part of my message. Read my message again.
Also, anything you can display in an HTML page you can also display as a splash screen. It can have images, DIV's, text, tables, whatever.
|
|
|
|
|
I have a sql server database table that contains documents that need to be downloaded from an internal site. The files are uploaded as varbinary(max) and I have the mime type for the file saved in the database (which will only be word and pdf, plus some wordperfect, files). Can someone let me know how I can pull those down from the database when a user needs to view the file? I'm already saving images in the database and I am able to pull those down using a http handler. Would that be the same process for this?
|
|
|
|
|
Aptiva Dave wrote: Would that be the same process for this?
Without knowing what your current process is that would be difficult to say.
Since an image is sent over the wire and rendered on the page it doesn't need additional processing. However, the file is on demand, when a user clicks a link it needs to be retrieved from the database and sent so a HTTPHandler would be necessary to process the request.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
and that is what I was kind of thinking. The way I am using the handler for images is that I point an image control's navigate URL to the handler ("www.mysite.com/ShowImage.ashx?ID=23"), which I can also use as a link for an image and pull up just fine as well. I couldn't find any good tutorials on the net that explained how docs were downloaded, just how they were uploaded. thanks.
|
|
|
|
|
So I tried implementing the same logic used to get images from the database, but instead of displaying the file my browser wants to open a file called DisplayResume.ashx.
Here is the code I used in my event Handler:
<%@ WebHandler Language="VB" Class="displayResume" %>
Imports System
Imports System.Web
Imports System.IO
Imports System.Data
Imports System.Data.SqlClient
Imports util
Public Class displayResume : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim appID As Integer
Dim mimeType As String
If Not context.Request.QueryString("ID") Is Nothing Then
'place ID in the the appID variable
appID = context.Request.QueryString("ID").ToString
'get the mimetype for the file from table
mimeType = getMimeType(appID.ToString)
If Not mimeType Is Nothing Then
context.Response.ContentType = mimeType
Dim strm As Stream = getResume(appID)
Dim buffer As Byte() = New Byte(4095) {}
Dim byteSeq As Integer = strm.Read(buffer, 0, 4096)
Do While byteSeq > 0
context.Response.OutputStream.Write(buffer, 0, byteSeq)
byteSeq = strm.Read(buffer, 0, 4096)
Loop
Else
Throw New ArgumentException("Can't retrieve MIME Type")
End If
Else
Throw New ArgumentException("No Parameter specified")
End If
End Sub
''' <summary>
''' Gets the mime type for the resume from the database
''' </summary>
''' <param name="appID">appID for the resume we are looking for</param>
''' <returns>mimetype string</returns>
''' <remarks></remarks>
Public Function getMimeType(ByVal appID As String) As String
Dim rdrMime As SqlDataReader = GetReader("select mimeType from resumes where appID =" & appID)
Dim mimetype As String = Nothing
Try
While rdrMime.Read
mimetype = rdrMime("mimeType").ToString
End While
Catch ex As Exception
Return Nothing
Finally
rdrMime.Close()
End Try
Return mimetype
End Function
''' <summary>
''' gets the binary format of the file from the database
''' </summary>
''' <param name="ID">appID that is pointing to the resume file</param>
''' <returns>binary representation of the resume file</returns>
''' <remarks></remarks>
Public Function getResume(ByVal ID As Integer) As Stream
Dim strConnection As String = ConfigurationManager.ConnectionStrings("connectionString").ToString
Dim conn As SqlConnection = New SqlConnection(strConnection)
Dim sql As String = "Select theFile from Resumes where appID = " & ID
Dim cmd As SqlCommand = New SqlCommand(sql, conn)
Try
conn.Open()
Dim file As Object = cmd.ExecuteScalar
Return New MemoryStream(CType(file, Byte()))
Catch ex As Exception
Return Nothing
Finally
conn.Close()
conn.Dispose()
End Try
End Function
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
|
|
|
|
|
Did you add the required settings in the web.config file?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
What setting would that be? I never have made any changes for displaying images before.
|
|
|
|
|
I'm sorry, you were writing and http handler, I thought you knew you need to add it the web.config file also.
http://support.microsoft.com/kb/308001[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Okay. I've never had to do that with my images, so i guess I never knew to add anything to the web config. I'm still confused as to what I need to set the path and type to in the add section under httpHandlers.
|
|
|
|
|
How to Protect XML from outside access in asp.net.
I have use
<configuration>
<location path="Login.xml">
<system.web>
<authorization>
<deny users="*"/>
</authorization>
</system.web>
</location>
</configuration>
But it doesn`t work online.
|
|
|
|
|
I'm pretty sure that's a setting you should be setting on the folder containing the XML file on the web server. Alternatively, you can embed the XML file in your application's DLL, which will make it inaccessible to the client side. Or you could store it in a database.
|
|
|
|
|
I have xml in root folder. I just want to stop viewing xml file from outside.
|
|
|
|
|
Hi All,
I developed a login page and added a link button(for logout) in all other pages. The code that I used behind logout is just Response.Redirect("Login.aspx")
So, when I click logout, it redirects me to the Login page but when I click back button in the browser, it goes into the application without the need of login.
Can anyone please help me how to do a safe logout in a web appliction so that even when I click back button it should not be entered into the application again without a proper login?
i've neither used a session variable nor FormsAuthentication. If I have to use session variables, please explain me how to use them(as I'm new to .NET). The code that I used in the login page is below:
Imports System.Data.SqlClient<br />
<br />
Partial Class Login<br />
Inherits System.Web.UI.Page<br />
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate<br />
Dim authentication As Boolean = False<br />
authentication = Sitelevelauthentication(Login1.UserName, Login1.Password)<br />
e.Authenticated = authentication<br />
If authentication = True Then<br />
Response.Redirect("Default.aspx")<br />
End If<br />
<br />
End Sub<br />
Private Function Sitelevelauthentication(ByVal Username As String, ByVal Password As String) As Boolean<br />
Dim boolretval As Boolean<br />
Dim con As New SqlConnection<br />
Dim Dr As SqlDataReader<br />
Dim sql As String<br />
con.ConnectionString = "Data Source=;Initial Catalog=;User ID=;Password="<br />
sql = "SELECT * FROM Login"<br />
con.Open()<br />
Dim cmd As New SqlCommand(sql, con)<br />
Dr = cmd.ExecuteReader()<br />
While Dr.Read()<br />
If Username = Dr("Username").ToString And Password = Dr("Password") Then<br />
boolretval = True<br />
End If<br />
Dr.Close()<br />
Return boolretval<br />
<br />
End While<br />
End Function<br />
End Class
Thank you,
Ranjani.
|
|
|
|